I want to use multiple ListView
/GridView
within same User Interface; I don't want them to be expanded to their full length and placed under ScrollView
.

- 7,659
- 9
- 48
- 84

- 1
- 2
4 Answers
I don't think that putting multiple ListView
/GridView
objects inside ScrollView
is a good idea.
The biggest advantage of ListView
/GridView
is that they reuse View
's. When you scroll a ListView
what the system really does is to use fixed number of views, and swaps the view settings (text, image source etc.). This is done by requesting the getView(int,View,ViewGroup)
method from the list Adapter
.
What you are trying to do is to force the ListView
/GridView
to render all it's raws, which pretty much beats the whole purpose of using ListView
/GridView
in the first place.
Use LinearLayout
inside the ScrollView
instead, and then add Views
dynamically from your Activity
/Fragment

- 790
- 5
- 16
-
I am not trying to use `ListView/GridView` inside `ScrollView` please read my question first. – Roger That... Aug 28 '13 at 14:37
Just specify dimensions to your ListView
/GridView
that are not all match_parent
.
Also, if you want to proportionally allocate say 50% and 50% of available height to your list and grid, put them in a LinearLayout
and use the layout_weight
mechanism:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
... />
<GridView
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
... />
</LinearLayout>

- 150,114
- 66
- 286
- 303
you can set the layout to include how many listViews and gridViews as you wish. just choose a layout and set their sizes yourself. if you put them in a linearLayout, you can set a weight for each of them, to make their width/height proportional to the layout width/height.
However, do note that the more you put, the more cluttered the UI is.
Also note that Google suggests to never put listViews and gridViews inside ScrollViews (this was being talked about on the "the world of listView" lecture) .

- 114,585
- 152
- 739
- 1,270