You should add the property android:scrollbars
with the value vertical
on your ListView to add the scrollbar in your listView:
<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"
android:scrollbars="vertical"/>
</RelativeLayout>
For the benefit of the community, I'll paste what did not work for me and what worked. This is the only post that helped fix the problem, others were just a lecture. Thanks to @Kurru
I have tried to reduce the crap. The areas to focus on are android:layout_height
android:layout_weight
.
Did not work
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="1dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content />
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbarSize="3dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:scrollingCache="true"
android:smoothScrollbar="true" />
</LinearLayout>
Worked
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="1dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:scrollbarSize="3dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:scrollingCache="true"
android:smoothScrollbar="true" />
</LinearLayout>
Those who still looking for the answer please visit this link you just need to do this inchild scroll view by adding android:nestedScrollingEnabled="true" to its XML declaration or by explicitly calling setNestedScrollingEnabled(true).
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.
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>