开发者

View still there but not visible after being moved out by animation

I have a small but annoying probleme with animations on views in Android.

What is involved: I have a FrameLayout in another FrameLayout contained in a xml.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <ListView
                android:id="@android:id/list"
                android:layout_height="fill_parent"
                android:layout_width="fill_parent"></ListView>
        <FrameLayout
                android:id="@+id/TopBanner"
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">
                <ImageView
                        android:id="@+id/ImageView01"
                        android:layout_width="fill_parent"
                        android:background="@drawable/topmenu"
                        android:layout_height="150dip"></ImageView>

                <Gallery
                        android:id="@+id/Gallery01"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"></Gallery>
        </FrameLayout>
</FrameLayout>

I also wrote an animation XML:

 <?xml version="1.0" encoding="utf-8"?>
<set
        android:interpolator="@android:anim/bounce_interpolator"
        xmlns:android="http://schemas.android.com/apk/res/android"
        fillEnabled="true"
        android:fillBefore="true"
        android:fillAfter="true">
        <translate
                android:dur开发者_运维问答ation="500"
                android:fromYDelta="0"
                android:toYDelta="-80%" />
</set>

What I want is to translate on click my inner frameLayout (topbanner) out of the activity view, except 20% of it, in order to make it re-appear when I click on it. A kind of top menu.

I managed to apply my animation, but even if my layout is translated, I can touch it as if it was still there. Any suggestion? Here is my java code:

@Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        UserSettings = getSharedPreferences("net.blabla_preferences", MODE_WORLD_WRITEABLE);

        tab = getIntent().getExtras().getInt("net.blabla.FigureTab");

        setContentView(R.layout.layout_figure_list);

        final Animation animation = AnimationUtils.loadAnimation(this, R.anim.animation_topbanner);
        topbanner = (FrameLayout) findViewById(R.id.TopBanner);


        topbanner.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                v.startAnimation(animation);
            }
        });

        load();

    }


EDIT: Things have changed since the advent of 3.0 Honeycomb. There is a whole new animation system to take advantage of, take a look here: Android Developer's Blog

Animations do NOT effect the 'physical' location of the views on screen. If you want it to actually move then you need to adjust the properties of the view.

An easier solution for your situation would be to use the SlidingDrawer widget that is included in the SDK. Since you are trying to achieve a pull out menu this seems like a perfect fit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜