小编MIL*_*L3S的帖子

将动画添加到ListView以展开/折叠内容

我有一个列表视图,它使用自定义适配器来显示我的自定义内容.它的布局如下.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">
        <ImageView
            android:id="@+id/itemimage"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="5"
            android:scaleType="fitCenter"/>
        <TextView
            android:id="@+id/itemdescription"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="10dp"
            android:textSize="16sp"
            android:layout_weight="1"/>
    </LinearLayout>    
    <TextView
            android:id="@+id/itemtext"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="TEXT CONTENT"
            android:layout_weight="1"/>
</LinearLayout>    
Run Code Online (Sandbox Code Playgroud)

我希望listview只显示带有ids itemimage和项目描述的视图,保持itemtext隐藏.我们的想法是在列表的每个项目上都有一个onclicklistener,以便扩展该项目,以便显示itemtext内容.我知道我应该使用补间动画来扩展/折叠每个项目,但我无法弄清楚如何做到这一点.

任何人都可以帮助我吗?如果您需要更多代码段,请随时提出.

提前致谢.

animation android listview collapse

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1

animation ×1

collapse ×1

listview ×1