Reputation: 797
In an activity, there is a ListView with the related adapter. Each item in this ListView has an ExpandableListView, with related adapter.
In the beginning, there are just two items in the ListView, and all the expandable listview is not expanded. At this time, the ListView's height is not larger than the screen's height(suppose the screen's height is 800, and the ListView's height is 600. there is a blank area with height 200 below the ListView).
Then I click the expandable listview in the first item, the expandable list view is expanded. However, the ListView's height is not changed (the blank area is still there).
Is there a method to adjust the listview's height so that the blank area could be removed when I click to expand the expanable list view? Thanks.
Upvotes: 4
Views: 1994
Reputation: 51
http://www.java2s.com/Code/Android/UI/setListViewHeightBasedOnChildren.htm
This helped me out. You basically have to keep track of the layout height. And use setLayoutParams()
and requestLayout()
to adjust it inside your onGroupExpand
and your onGroupCollapseListener
methods.
Upvotes: 2