查看仍然存在,但不可见的动画被搬出后 [英] View still there but not visible after being moved out by animation

查看:86
本文介绍了查看仍然存在,但不可见的动画被搬出后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小,但恼人的probleme与意见动画的Andr​​oid系统。

什么是参与: 我已经包含在一个XML另外的FrameLayout一个的FrameLayout。

 < XML版本=1.0编码=UTF-8&GT?;
<的FrameLayout
        的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT>

        <的ListView
                机器人:ID =@机器人:ID /列表
                机器人:layout_height =FILL_PARENT
                机器人:layout_width =FILL_PARENT>< / ListView控件>
        <的FrameLayout
                机器人:ID =@ + ID / TopBanner
                的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT>
                < ImageView的
                        机器人:ID =@ + ID / ImageView01
                        机器人:layout_width =FILL_PARENT
                        机器人:背景=@可绘制/顶部菜单
                        机器人:layout_height =150dip>< / ImageView的>

                <画廊
                        机器人:ID =@ + ID / Gallery01
                        机器人:layout_width =FILL_PARENT
                        机器人:layout_height =WRAP_CONTENT>< /画廊>
        < /的FrameLayout>
< /的FrameLayout>
 

我还写了一个动画的XML:

 < XML版本=1.0编码=UTF-8&GT?;
<集
        机器人:插=@机器人:动画/ bounce_interpolator
        的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        fillEnabled =真
        机器人:fillBefore =真
        机器人:fillAfter =真正的>
        <翻译
                机器人:时间=500
                机器人:fromYDelta =0
                机器人:toYDelta = -  80%/>
< /集>
 

我要的是为翻译上点击我内心的FrameLayout(topbanner)从活动视图,除了它的20%,以使其重新出现时,我一下就可以了。一种顶级的菜单。

我设法申请我的动画,但即使我的布局被翻译 我可以触摸它,如果它仍然存在。任何建议?这是我的Java code:

  @覆盖
    保护无效的onCreate(包savedInstanceState){

        super.onCreate(savedInstanceState);
        UserSettings = getShared preferences(net.blabla_ preferences,MODE_WORLD_WRITEABLE);

        标签= getIntent()getExtras()调用getInt(net.blabla.FigureTab)。

        的setContentView(R.layout.layout_figure_list);

        最终的动画动画= AnimationUtils.loadAnimation(这一点,R.anim.animation_topbanner);
        topbanner =(的FrameLayout)findViewById(R.id.TopBanner);


        topbanner.setOnClickListener(新OnClickListener(){

            公共无效的onClick(视图v){
                v.startAnimation(动画);
            }
        });

        加载();

    }
 

解决方案

编辑: 由于3.0蜂窝的出现一切都变了。有一个全新的动画系统来利用,看看这里:<一href="http://android-developers.blogspot.com/2011/02/animation-in-honeycomb.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+blogspot%2FhsDu+%28Android+Developers+Blog%29"相对=nofollow> Android开发者博客

动画不会影响屏幕的意见物理的位置。如果你想让它实际移动,那么你需要调整视图的属性。

您的具体情况更简单的解决办法是使用 SlidingDrawer 插件被包括在SDK。既然你正在努力实现一个拉出来的菜单,这似乎是一个完美的结合。

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:duration="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.

这篇关于查看仍然存在,但不可见的动画被搬出后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆