How to make a list view to grow instead of scroll?
I have a ListView, in which i have added a header. the header contains, another ListView. I want the ListView in the header to grow instead of scroll with limited size.
This I am inflating in the header
<ListView android:id="@+id/songinfo_geninfolist"
android:isScrollContainer="false" android:layout开发者_JAVA百科_marginLeft="10dip"
android:layout_margin="5dip" android:padding="5dip"
android:scrollbars="none"
android:layout_height="wrap_content" android:layout_width="match_parent">
</ListView>
and this xml is for the main list
<ListView android:id="@+id/songinfo_linklist"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="10dip" android:layout_margin="5dip"
android:layout_height="match_parent" android:layout_width="match_parent">
</ListView>
but i am getting a list with header containing a list with a small height. i want the list in header to grow with the content.
If you want your List to grow with its content, don't use a ListView. Use i.e. a LinearLayout and add the elements to that.
You can also try to give the upper ListView a fixed height (i.e. 100dip) and let the bottom ListView take the rest of the space.
Also you have to know that the layout_heigth parameter works differently in comparison other Widgets/Layouts. I.e. wrap_content does not make sense, because a ListView can display thousands of items and that would eat the whole memory.
If you want use ListViews you should have watched the google io session world of listview by romain guy.
精彩评论