0

I want my listview rows to fill all the screen. For example if I have 4 rows I want the screen to be filled with all the rows taken even space within the screen. Right now the list only take 1/3 of screen.

activity_subject.xml

 <?xml version="1.0" encoding="utf-8"?>
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin"
            android:orientation="vertical"
            tools:context=".SubjectListActivity">

            <ListView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@android:id/list"/>
        </LinearLayout>

row_layout.xml // the list row layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="horizontal"
              android:layout_width="match_parent"
              android:layout_height="match_parent">


    <Spinner
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/spinner_list_view"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/list_text_view"
        android:textSize="25sp"
        android:textStyle="bold"
        android:padding="15dp"/>




</LinearLayout>
  • Possible duplicate of [ListView to cover entire screen in Android](http://stackoverflow.com/questions/11044595/listview-to-cover-entire-screen-in-android) –  Mar 09 '16 at 08:22
  • activity_subject.xml is attached to an activity or a fragment ?? – Fakher Mar 09 '16 at 08:28

2 Answers2

1

Try to change parent layout from LinearLayout to RelativeLayout.

Gent
  • 6,215
  • 1
  • 37
  • 40
0

Try this in ListView:

Make android:layout_height="0dip"

and add android:layout_weight="1"

Yogesh Umesh Vaity
  • 41,009
  • 21
  • 145
  • 105