10

In my app I am using a ListView and it is inside a NestedScrollView. When I set height of the ListView to match_parent it does not cover the whole screen. I want that ListView to cover the whole screen.

My XML file:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:isScrollContainer="false"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill_vertical"
        android:clipToPadding="false"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:paddingTop="1dp">

        <ListView
            android:id="@+id/list"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:divider="@null" />
        </LinearLayout>
</android.support.v4.widget.NestedScrollView>
davidweitzenfeld
  • 1,021
  • 2
  • 15
  • 38

3 Answers3

42

Add this to your NestedScrollView

android:fillViewport="true"
amzer
  • 640
  • 4
  • 16
3

android:fillViewport="true"

This makes the list view cover the entire device screen but in case there is much data, it does not enable scrolling. You can view its results from this image

Neri
  • 738
  • 1
  • 8
  • 19
-1

i am not sure this will help you problem but i fix my problem like you with this solution

 <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:minHeight="@dimen/min_height"> //minimum height for listview
yemonkyaw
  • 52
  • 2
  • 6
  • please try with remove Linear Layout above listview or add "android:minHeight="@dimen/min_height" " in the Linear Layout – yemonkyaw Sep 02 '15 at 12:03