0

I have an activity with the following plan of layouts:

__________
|TextView|
|        |
|ListView|
|........|
|........|
|........|
|........|
|........|
|........|    
|TextView|
|TextView|
|********|
----------

All the views are filled dynamically, therefore, could be of varying size. Ofcourse, all of it can't fit into the screen all at once. I want all the content of my activity to be scrollable - top to bottom. Therefore, I'm planning to wrap-up everything in one single ScrollView.

But, when I try to do so, only one item of the ListView gets displayed. How could I resolve this?

UPDATE:

Adding a header and a footer layout to the ListView eventually solved my problem. Didn't try other answers though.

Also, I had to add the header/footer before setting the adapter to the ListView. Adding them after the adapter was screwing up the UI as it was updating.

Akeshwar Jha
  • 4,516
  • 8
  • 52
  • 91
  • Try putting a layout_weight value of 1 for the list view. Also, a scrollview can only have one descendant so make sure all the views are wrapped in a viewgroup and then put in the scrollview. – chRyNaN Mar 05 '16 at 20:03

4 Answers4

1

A better solution is to move everything above the listview into a View that you load as a header to the ListView, and everything below the ListView as another view that you load as the footer of the ListView. That way everything scrolls and you do not have touch conflicts as you would by wrapping a listview in a scrollview.

Add header

Add footer

Francesc
  • 25,014
  • 10
  • 66
  • 84
0

Don't put a ListView inside a ScrollView. Instead, put the individual items from the ListView into the LinearLayout that's being scrolled by the ScrollView.

ScrollView doesn't work well when putting other scrolling elements inside it.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
0

You can find a lot of solution options for the unrecommended (but yet common) "ListView inside a ScrollView" problem on this site. for example: one, two, three (three is similar to Francesc suggestion), and many other solutions if these ones are not working for you...

Community
  • 1
  • 1
e-shfiyut
  • 3,538
  • 2
  • 30
  • 31
0

Create a linear layout to store each item of listview and make that layout scroll able i think that is the best way.

Zaigham Raza
  • 364
  • 2
  • 3
  • 14