Wednesday, December 8, 2010

Android: put ListView in a ScrollView

When I need to use ListView with other controls on the same screen, and it doesn't fit the screen vertically, I wish to get ScrollView over all controls, to scroll entire screen. But, that's the point when "shit happens".

Android core developers say you "must not put ListView inside ScrollView", because of many reasons, one of them - ListView has it's own scroll.

When you try just do it, ListView collapses, and you wish it not to be collapsed at all.

To accomplish that, I use a "hack", measuring and setting the height directly: