0

I am trying to put multiple lists that don't need to be scrollable inside a ScrollView. In other words, I have a TextView as a header for a category, with a list under it. Then another TextView as another header, with another list under that. And so on. This is in a vertical LinearLayout.

I want to be able to scroll through this layout as it gets off the screen when it has too much info, but I want all the contents of the lists to be displayed.

I've tried putting the headers (the TextViews) and the lists inside a vertical LinearLayout, and that LinearLayout inside a ScrollView. The problem with that approach is - all the lists have a max vertical dimension of exactly one element (if I set them to "wrap content"), despite the lists having multiple elements. Believe it or not, the lists do scroll (and they're inside of a ScrollView, more exactly, inside of a ScrollView -> LinearLayout).

If I remove the ScrollView, then the lists do indeed appear with all their elements, but I can't scroll the view if it goes off the screen.

So, if I use a ScrollView, I only get one element per each list. If I don't use it, I get all the elements of the lists correctly, but it doesn't scroll.

Any ideas of solving this? Thanks!

Robert Ruxandrescu
  • 627
  • 2
  • 10
  • 22
  • ListView with custom adapter. Use index to inflate header and items from two different layouts as required. – Rohit5k2 Dec 06 '16 at 10:16

1 Answers1

0

Nevermind, eventually found the answer here and it works perfectly:

https://stackoverflow.com/a/27818748/5627584

This ^^^ is a very underrated answer as I have hardly found it, but it's very, very useful when trying to include lists inside of superior layout node that has to be scrollable (inside of a ScrollView -> LinearLayout that contains other interface elements).

Community
  • 1
  • 1
Robert Ruxandrescu
  • 627
  • 2
  • 10
  • 22