Reputation: 3208
I am using a listview in a layout with a size- not in full size of layout. Below the layout there are components like button. I need the layout to get extended when more number of listitems adds dynamically.
I have kept the listview and buttons in scrollview.
Is there any attribute or option to make listview of variable length
Upvotes: 3
Views: 268
Reputation: 24235
You should not have a listview inside a scrollview. Instead of having a listview you should add your items to a linearlayout, which will grow to accomodate the items and not enable the scrollbar within itself. This will solve your UI issue. You can set the onclickListeners in a for looop.
<ScrollView.....>
<LinearLayout .....>
<LinearLayout ..../> // this has your list items
<Button .... /> // you can have a layout here if you have multiple buttons.
</LinearLayout>
</ScrollView>
Upvotes: 1
Reputation: 81349
Set the ListView
's layout_height
value to wrap_content
, and it will stretch to accomodate all the items' views in its adapter.
Upvotes: 0