So I am developing a screen where there are some images and buttons on top and Below that is a list view which shows a list of some activity.
The design is something like this :-
Now on smaller screen the ListView height becomes very small as the screen space is taken up by the above icons and images.
So how can i increase the height of the Linearlayout or ListView so that user can scroll to the see the rest of the ListView.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
.... Other Layouts .....
<ListView
android:id="@+id/listArea"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:paddingLeft="@dimen/list_padding"
android:paddingRight="@dimen/list_padding" />
</LinearLayout>
Edit: Tried using the top view as a header to the List but since I want an EmptyView too, this is creating a problem as it replaces the whole header + listview
You can use the weightSum and layout_weight attributes to control how much of the parent's available space a child view will take up. To use these, a parent layout, for example, your LinearLayout, gets the
android:weightSum
attribute. Each child layout gets theandroid:layout_weight
attribute, where the sum of all child weights is the weightSum of the parent. In addition, each child should have theirlayout_height
orlayout_width
set to0dp
, whichever is going to be decided by the weight.Here's an example based on your diagram. Let's say you want the two top views to take up 1/4 of the screen each, and the
ListView
to take up the bottom half. Addandroid:weightSum="4"
to yourLinearLayout
,android:layout_weight="1"
to the two child layouts that you represent with...Other Layouts...
, andandroid:layout_weight="2"
to theListView
. Code might look something like this:From what I read about that issue, you should specify the Views on top as header of the list, and the'll scroll properly.
Afaik this only works if the list is non-empty, as the empty view replaces the whole list including headers.