Android的 - 布局动画不会留在上面布局、动画、Android

2023-09-06 01:20:08 作者:你跟我俩潮愣啥??

我需要2个屏幕的自定义动画象下面这样解释的:

I need to make 2 screens with custom animation like explained below :



          Screen 1                                    Screen 2
 -----------------------------              ------------------------------
|                   |         |            |        |                     |
|                   |         |            |        |                     |
|                   |         |            |        |                     |
|       List 1      |  List2  | ---------> | List 3 |      List 4         |
|   (75% width)     |(25% wid)|            |(25%wid)|   (75% width)       |
|                   |         |            |        |                     |
|                   |         |            |        |                     |
 -----------------------------              ------------------------------

在用户进行了长时间的接触中的项目清单1和幻灯片从左至右。 包含列表1移动由左到右(到屏幕的末尾)和淡入淡出的看法。屏幕2所示。

我已经把每一个列表的的LinearLayout 所有的的LinearLayout s被包含在一个根的LinearLayout 。经过对的List1 检测左向右轻扫,我这样做

I have put each of the lists in a LinearLayoutand all the LinearLayouts is contained in a root LinearLayout. After detecting the left to right swipe on List1, I do this



                        AnimationSet set = new AnimationSet(true);

                        Animation animation = new TranslateAnimation(
                            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.75f,
                            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f
                        );
                        animation.setDuration(500);
                        animation.setZAdjustment(Animation.ZORDER_TOP); // Keep the viewgroup on which this animation applies at the top.
                        set.addAnimation(animation);

                        LayoutAnimationController controller =
                            new LayoutAnimationController(set, 0.0f);

                        screenOne_layoutOne.setLayoutAnimation(controller);
                        screenOne_layoutOne.startLayoutAnimation();

我能得到的动画,但 screenOne_layoutOne (包含列表布局1 )不留在上面。动画低于列表2

I was able to get the animation but the screenOne_layoutOne(layout containing the List 1) doesn't stay on top. The animation goes below List2.

谁能告诉我问题出在哪里?

Can anyone tell me where the problem is?

在此先感谢。

推荐答案

对于那些谁感兴趣的话,我能得到这个解决通过把两个画面的布局,在一个布局文件,并修改知名度的布局/意见。所用的布局文件是

For those of you who are interested, I was able to get this solved by putting the layouts of both the screens in a single layout file and changing the visibility of the layouts/views. The layout file used is

<LinearLayout android:id="@+id/featured_view_container"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:visibility="visible" >

    <ListView android:id = "@+id/featured_list"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2" />

    <ImageView android:layout_height = "match_parent" 
        android:layout_width="wrap_content"
        android:src="@drawable/seperator"/>

    <LinearLayout android:id = "@+id/categories"
        android:orientation="vertical"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1" />

</LinearLayout>

<!-- Layout for the screen 2-->
<LinearLayout android:id="@+id/category_view_container"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:visibility="gone" >

    <LinearLayout android:id = "@+id/subcategories"
        android:orientation="vertical"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1" />

    <ImageView android:layout_height = "match_parent" 
        android:layout_width="wrap_content"
        android:src="@drawable/seperator"/>

    <ListView android:id = "@+id/subcategory_list"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2" />

</LinearLayout>

当我申请上List1中( featured_list )动画(动画),它停留在上面,如果我这样做

when I applied the animation(anim) on list1(featured_list), it stays on top if I do

                    anim.setZAdjustment(Animation.ZORDER_TOP)
 
精彩推荐
图片推荐