【发布时间】:2015-08-16 16:59:47
【问题描述】:
在我的示例项目中,我有一个线性布局,它的高度设置为在 xml 中包装内容,并且它下面还有一个片段,它占用了所有剩余空间。片段包含一个按钮,单击该按钮将删除片段,并且线性布局的高度设置为匹配父级。我尝试添加android:animateLayoutChanges="true",但从 wrap_content 到 match_parent 的过渡并不顺利。我如何从android:layout_height="wrap_content" 动画到android:layout_height="match_parent"
这是布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
android:orientation="vertical"
android:id="@+id/layoutRoot"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/cloudHolder"
android:orientation="vertical"
android:animateLayoutChanges="true"
android:gravity="center"
android:layout_height="wrap_content">
<ImageButton
android:layout_width="100dp"
android:layout_gravity="center"
android:layout_height="100dp"
android:background="@drawable/play"/>
</LinearLayout>
【问题讨论】:
-
如果您发布您的 xml,则更容易给出明确的建议。
-
@Christian 我已经编辑了我的问题