首页 > 解决方案 > 嵌套的listView在cardView中没有全尺寸

问题描述

我需要帮助。我有一个包含不同视图的 RecyclerView,例如 Cardviews。这些 CardViews 包含一个 ListView

cardViews 高度是包装内容,listviews 高度也是包装内容。

第一张卡片中的 listView 包含三个项目,第二张卡片只有一个,最后一张卡片有一个子项。

如果卡片的内容发生变化或可扩展列表视图打开,我如何存档卡片的增长

我很抱歉我的英语不好

视图截图 在此处输入图像描述

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.v7.widget.CardView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/card_vocdetail_general"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:orientation="vertical">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <ExpandableListView
            android:id="@+id/card_vocdetail_expandableList"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:minHeight="48dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <LinearLayout
            android:id="@+id/card_vocdetail_more"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"

    app:layout_constraintTop_toBottomOf="@+id/card_vocdetail_expandableList">

            <TextView
                android:id="@+id/card_vocdetail_more_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/card_detail_voc_more_sides"
                app:layout_constraintStart_toStartOf="parent"

    app:layout_constraintTop_toBottomOf="@+id/card_vocdetail_expandableList" />

            <TextView
                android:id="@+id/textView28"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:clickable="true"
                android:gravity="end"
                android:text="@string/show_more" />
        </LinearLayout>

    </LinearLayout>

</android.support.v7.widget.CardView>

标签: androidlistviewexpandablelistviewcardview

解决方案


推荐阅读