在Android中,如何折叠和展开布局?

在Android中,如何折叠和展开布局?,android,android-layout,Android,Android Layout,我想把它用作recyclerview的物品 之前 之后 问题: 我想要的是,当我点击红色部分,然后黄色部分(在点击前折叠)将被打开 有什么好办法吗?请给我讲课 这是我的post_item.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_co

我想把它用作recyclerview的物品

之前

之后

问题: 我想要的是,当我点击红色部分,然后黄色部分(在点击前折叠)将被打开

有什么好办法吗?请给我讲课

这是我的post_item.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/tv_like_count"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#ff0000"
        android:minHeight="100dp"/>

    <ImageView
        android:id="@+id/iv_post_img"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#ffee58"
        android:minHeight="100dp"/>

</LinearLayout>


听说过ExpandableListViews吗?@Rotwang,我听说过,但这是否适用于此?因为我对ExapndableListViews了解不多,所以我认为这是针对类似list的东西。如何应用ExpandableListView?你能让我得到一些提示吗?如果你有一个元素列表,这是合适的。如果你只有几排。。。那么你真的应该走一条简单的路:利用点击行的高度。听说过ExpandableListView吗?@Rotwang,我听说了,但这适合这个吗?因为我对ExapndableListViews了解不多,所以我认为这是针对类似list的东西。如何应用ExpandableListView?你能让我得到一些提示吗?如果你有一个元素列表,这是合适的。如果你只有几排。。。然后,您应该使用简单的方法:调整单击行的高度。