I have one layout. This layout contain 3 list view with the height of wrap_content data in the Listview are not fix. When Listview have a liitel huge data at that time the data
If you are presenting stuff in a vertical or horizontal stack, you should be using LinearLayout
and then use the layout_weight
attribute to control the proportions of the individual rows/columns within the container.
If you want screen-sized, set the layout_width
and layout_height
to fill_parent
otherwise you will not get all available screen dimension. If you try to use wrap_content
for height, everything will collapse, unless you resort to additional layout constraints, e.g. minHeight
.
We use this everywhere and it is quite reliable. For three items, you can use 1/1/1
or 3/3/3
.
The weights also do not have to be equal! You can divide up the proportions any way you wish; the weights are just relative ratios of the entire span (width/height). E.g. if you want the middle element twice the size, use 1/2/1
; if you want it 40% use 30/40/30
or 3/4/3
.
A good "trick" is to use layout_weight
=1 on exactly one row/column (others default to zero), and it will "fill-in" any remaining space. This is a common layout scenario.
If you need the stack to be scrollable, you can put it into a ScrollView
. In this case, you must set the layout_height
of the LinearLayout
to wrap_content
, and you will be subject collapsing depending on the whim of the layout system (meaning you need to then use min/max constraints).