Take the 2-minute tour ×

I have several ListViews in a LinearLayout. It's listing things by day, so I have a TextView containing "Sunday:" followed by a list of items, followed by a "Monday" TextView, etc. Works great, but doesn't fit in the screen. So I added a ScrollView as a parent of the LinearLayout. Now it scrolls, but the ListViews all have room for 2 entries, whether they have 0 or 3 entries. Something about adding the ScrollView parent caused the ListViews to not size dynamically. I tried calling requestLayout() on the ScrollView after the list adapters had filled their views, but that didn't do anything. Any ideas?

Edit: From http://www.anddev.org/viewtopic.php?p=25194 and other links it seems that ListViews inside a ScrollView are not handled correctly. Anyone have a good suggestion for implementing a list-of-lists?

share|improve this question
Could you post your layout xml? Have you set android:layout_height="wrap_content" or similar in your ListViews? –  svens Oct 6 '09 at 17:13
I don't have access to the layout at the moment.. All of the views inside the LinearLayout have layout_height="wrap_content", the LinearLayout and ScrollView have layout_height="fill_parent" (tried wrap_content on the LinearLayout). Commenting out the ScrollView, everything lays out correctly, but goes off the screen.. –  Aaron Oct 6 '09 at 17:40
Get your ListViews into a ListView ? :) If I understand it correctly you want to make a list of all weekdays in a TextView with a ListView below it. This should be implementable in a custom adapter. See the answer my question stackoverflow.com/questions/1505751/… which describes how to extend ResourceCursorAdapter. Maybe this helps you to build an adapter which fills a ListView with your weekday ListViews+Caption. –  svens Oct 6 '09 at 18:20
add comment

3 Answers

up vote 13 down vote accepted

I'm interested in that topic too, so I did a bit of research. First: Never put a ListView in a ScrollView (as you found out yourself). Unfortunately googling this problem doesn't lead to any solutions, so I tried my suggestion from my comment above.

I implemented a custom ListAdapter and put the ListViews into one parent ListView. This doesn't work (leads to the same problem as with a ScrollView). Speaking to the guys on the official android-irc #android-dev on freenode, they told me that putting ListViews into a ListView is as bad as or even worse than putting them into a ScrollView. Unfortunately they also couldn't help me with the problem.

There seems to be only one way to achieve what you want to do; see the answer on this similar question http://stackoverflow.com/questions/306626/scrolling-with-multiple-listviews-for-android . The idea is to merge all ListViews into a single one by a custom adapter and to insert some kind of headers between entries. This is absolutely doable but might require some special effort.

share|improve this answer
Seems like my only option.. –  Aaron Oct 6 '09 at 23:18
why should you not put listviews inside scrollviews? –  MalcomTucker Aug 12 '10 at 21:52
because they explode. –  stealthcopter Jun 20 '11 at 23:04
add comment

I know it's late to answer this right now, but still - it may be useful to others who arrive here in case of similar problems.

I'd suggest that you use an Expandable ListView for this. It would solve all of your problems. You can have the main/parent names as that of week, and when you expand it, you would have the list of entries for that particular day/week/whatever. Also, you wouldn't have to worry about scrolling as it is taken care by android :)

If you DO try this, then please let me know if this works out for your problem Try searching for examples on Expandable ListView.

edit:check example here - http://mylifewithandroid.blogspot.com/2008/05/expandable-lists.html

share|improve this answer
really, Expandable List Views are the way to go –  Axarydax Jan 13 '11 at 8:57
add comment

You can use this solution - ListView in ScrollView

share|improve this answer
That's an unreliable and bad solution. More of a hack. –  Artem Russakovskii Jun 17 '11 at 22:27
add comment

Your Answer


