Reduce ListView height when there are fewer items

88 Views Asked by At

I have ListView to be used in the app widget. The list view has a fixed height of some 140 dp to accommodate 3 items, now when there is only one item to show, there is space left below the item. I want to be able to set the list view like this - set wrap_content and a maximum height. Is this possible?

1

There are 1 best solutions below

1
Abdus Sattar Nishad On

when you use fixed height it will always take that height no matter how many items u have. In that case u can use maxHeight and set it to 140 dp.So when u have less item the height will reduce. If u have shared the code and a image it would have been better.