There is a conflict between ScrollView and ListView . In general, you cannot put a ListView inside a ScrollView . ListView already understands scrolling and will scroll itself. ListView needs to know how much vertical space on the screen it needs to use so that it can control the scrolling and display of its children. It's hard to understand how the layout you published should behave.
In any case, the only way to place a ListView inside a ScrollView is to tell ListView exactly how much vertical space it should use. You cannot use match_parent or wrap_content for layout_height , you need to fix the vertical size. This helps ScrollView determine how much vertical space each of its children occupies, and then ScrollView can do it right.
Try setting android:layout_height="80dp" to all your ListView to see how this happens.
EDIT: looking at the layout again, I have another suggestion
If you look at the layout again, I assume that you want to see only one of the ListView at the moment (the rest will be GONE ). In this case, you can try the following:
- Remove the surrounding
ScrollView - Set
android:layout_weight="1" and android:layout_height="1px" on all ListView s
Basically, this tells the layout manager that the ListView should be provided with all the available space on the screen (i.e.: everything that remains after another View laid out). This will lead to the fact that the ListView extension will occupy all the free space on the screen, retaining all the other View on the screen, and the whole screen will not scroll, only the ListView . This may be the best way to give you what you want.
You might also consider using an ExpandableListView , which seems to be what you are trying to recreate here.
source share