我有一个ListView只显示一个项目。如果我将ListView设置为一个高度,我可以看到所有项目都被加载到它中,但wrap_content仅显示第一行。Android ListView只显示第一项
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.fmsirvent.ParallaxEverywhere.PEWImageView
android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="370dp"
android:layout_gravity="center"
android:contentDescription="@string/show_logo"
android:scaleType="centerCrop" />
<GridView
android:id="@+id/hostGrid"
android:layout_width="match_parent"
android:layout_height="240dp"
android:layout_gravity="center"
android:columnWidth="100dp"
android:numColumns="auto_fit" />
<TextView
android:id="@+id/showDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textSize="20sp" />
<ListView
android:id="@+id/showListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
更新:截图
对于ListView的高度,不要使用'wrap_content'。你可以在那里做'match_parent',它会占用'LinearLayout'中剩下的空间,因为这是最后一件事。 –