Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my listview not scrolling?

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#dad4c8"
    android:gravity="center_horizontal">
    <include
        android:id="@+id/title_bar"
        layout="@layout/title_bar" />
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/title_bar"
        android:id="@+id/txt"
        android:hint="Song title" />

    <ListView
        android:cacheColorHint="#00000000"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/txt"
        android:id="@+id/list" />

</RelativeLayout>
like image 834
hunterp Avatar asked Aug 26 '11 21:08

hunterp


1 Answers

Use a LinearLayout and set the ListView's Height to 0dip and give it layout_weight="1"

This will make it autofill any remaining space, causing the internal items of the list view to scroll. Currently the listview is very tall and is being clipped by the bounds of the screen.

Edit

Something like this:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#dad4c8"
    android:orientation="vertical"
    android:gravity="center_horizontal">
    <include
        android:id="@+id/title_bar"
        layout="@layout/title_bar" />
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txt"
        android:hint="Song title" />

    <ListView
        android:cacheColorHint="#00000000"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:id="@+id/list" />

</LinearLayout>
like image 123
Kurru Avatar answered Oct 13 '22 08:10

Kurru