LinearLayout动画在其他视图后面

时间:2013-08-07 10:17:45

标签: android animation

我目前正在Android中编写应用程序,但我的动画有问题。为了简化,我在水平线性布局中有三个“对象”(两端有两个按钮,中心有一个垂直线性布局,我想要制作动画)。问题是,当我尝试向左移动它时,它会越过按钮(我希望它在后面)。当我试图将它向右移动时,它会在按钮后面传递(就像我想要的那样)。

在这个主题中,我认为也是同样的问题,但没有答案:( Android animation behind other views

我已经尝试了setZAdjustment(Animation.ZORDER_BOTTOM)动画,但它没有改变任何内容。

有什么想法吗?

我的Java代码非常简单:

layout_main= (LinearLayout)this.findViewById(R.id.main_layout);
moveNext= AnimationUtils.loadAnimation(this, R.anim.move_next_seq);
moveNext.setZAdjustment(Animation.ZORDER_BOTTOM);
layout_main.startAnimation(moveNext);

我的xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<ImageButton
    android:id="@+id/button_previous"
    android:layout_width="@dimen/next_previous_button_width"
    android:layout_height="fill_parent"
    android:background="@drawable/button_classic"
    android:contentDescription="@string/button_previous_description"
    android:src="@android:drawable/ic_media_previous" />

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

<ImageButton
    android:id="@+id/button_next"
    android:layout_width="@dimen/next_previous_button_width"
    android:layout_height="match_parent"
    android:background="@drawable/button_classic"
    android:contentDescription="@string/button_next_description"
    android:src="@android:drawable/ic_media_next" />

和我的动画:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true"
    android:interpolator="@android:anim/linear_interpolator" >

<set>
    <translate
        android:duration="300"
        android:fromXDelta="0%"
        android:startOffset="300"
        android:toXDelta="-100%" />
    <translate
        android:duration="1"
        android:fromXDelta="-100%"
        android:startOffset="600"
        android:toXDelta="100%" />
    <translate
        android:duration="400"
        android:fromXDelta="100%"
        android:startOffset="601"
        android:toXDelta="0%" />
</set>

0 个答案:

没有答案
相关问题