微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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小部件.由于您正在尝试实现拉出菜单,这似乎是一个完美的契合.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐