I have a ListView that is only showing one item. If I make the ListView a set height, I can see that all the items are getting loaded into it, but the wrap_content is only showing the first row.
<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>
Update: screenshot
Generally you want a ListView, RecyclerView, etc to take up all of the remaining space and perhaps have a minimum height. Since you've got yours in a LinearLayout, this will work nicely:
<ListView
android:id="@+id/showListView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
If you find it's too small on some devices, you will need to put the LinearLayout into some sort of ScrollView and set a minimum height on the ListView.
To do that, you will need to use a NestedScrollView . The best way to achieve this will be something like this:
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
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="match_parent" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.