簡體   English   中英

CardView中包含的ListView沒有顯示完整長度

[英]ListView contained in a CardView is not showing full length

我在cardview內部有一個listview,盡管它的高度設置為wrap_content,但它不能擴展為適合listview的整個大小。 它僅顯示第一項。

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="@+id/rootCardView"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#FEFEFE"
android:layout_margin="8dp">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/textPrimary"
        android:textSize="20sp"
        android:textStyle="bold"
        android:layout_alignParentTop="true"
        android:id="@+id/card_title"
        android:layout_marginTop="16dp"
        android:layout_marginStart="16dp"/>

    <!-- Main ListView -->
    <ListView
        android:id="@+id/cardsList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none"
        android:layout_below="@+id/card_title">
    </ListView>
</RelativeLayout>


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

如果我為卡的高度設置了一個確定的大小,它會起作用,但這沒有用,因為列表視圖的大小會經常更改。 有什么辦法可以讓卡片正確顯示整個列表視圖?

如果設置android:minHeight屬性呢?

有了這個,您仍然會擁有android:layout_height="wrap_content"但是您還將擁有想要看到的最小高度。

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM