为什么animateLayoutChanges会在动画结束前移动兄弟视图的位置?

时间:2015-12-06 09:05:06

标签: android android-layout android-animation

我有以下XML代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/viewGroup"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:animateLayoutChanges="true"
            android:orientation="vertical">

            <RelativeLayout
                android:id="@+id/textLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
            </RelativeLayout>

            <ListView
                android:id="@+id/testList"
                android:layout_width="match_parent"
                android:layout_height="75dp"
                android:visibility="gone" />
        </LinearLayout>

        <RelativeLayout
            android:id="@+id/anotherLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <ListView
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <TextView
                android:id="@+id/messageText"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center" />
        </RelativeLayout>
    </LinearLayout>
</LinearLayout>

因此,点击textLayout后,它将确定testList的可见性。

当可见性变为VISIBLE时,效果很好。但是,当可见性变为GONE时,anotherLayout会在viewGroup的动画结束之前返回到原始位置,因此它会与testList重叠。

我该如何防止这种情况?

0 个答案:

没有答案