android – 查看仍然存在但在被动画移出后不可见

我对Android中的视图动画有一个小而烦人的问题.

涉及的内容
我在另一个包含在xml中的FrameLayout中有一个FrameLayout.

<?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>

我还写了一个动画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:duration="500"
                android:fromYDelta="0"
                android:toYDelta="-80%" />
</set>

我想要的是在活动视图中点击我的内部frameLayout(topbanner),除了它的20%,以便在我点击它时重新出现.一种顶级菜单.

我设法应用了我的动画,但即使我的布局被翻译,我也可以触摸它,好像它仍然在那里.有什么建议吗?这是我的java代码

@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();

    }

解决方法:

编辑:
自从3.0 Honeycomb问世以来,情况发生了变化.有一个全新的动画系统可以利用,看看这里:Android Developer’s Blog

动画不会影响屏幕上视图的“物理”位置.如果您希望它实际移动,那么您需要调整视图的属性.

对于您的情况,更简单的解决方案是使用SDK中包含的SlidingDrawer小部件.由于您正在尝试实现拉出菜单,这似乎是一个完美的契合.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...