我有一个带有 layoutAnimation
属性的 LinearLayout
,用于自定义 ExpandableListView
。像这样:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layoutAnimation="@drawable/list_layout_controller"
android:orientation="vertical" >
当我点击列表时,会显示动画。但它只工作一次,并且不会在下一次点击时为列表设置动画。为什么?
如果您需要更多说明,请告诉我。
谢谢
最佳答案
布局动画在 View 添加到布局时运行。因此,您必须在每次展开/折叠时手动添加/删除 View ,布局动画才能正常工作。
为此,您可以维护一个以列表索引为键的 View 映射。 每次点击时,只需从 map 中选择相应的项目并添加到您的布局中即可。动画将在该 View 上运行,您的问题已解决。
您也可以尝试在 onClick()
中更改 View 的可见性。但不确定这一点。
试试让我知道。
希望对您有所帮助。
关于android - layoutAnimation 只工作一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10163928/