我有以下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
重叠。
我该如何防止这种情况?