I have to make a simple layout in android but have problem with the heigh of the central element. basically I have a header, a body and a footer. header and footer have fixed height but I’d like the body to fill the remaining space. this should be screen size independent so I’d like the height of the body to be dynamically worked out when the layout is being rendered.
do you guyz know how I can achieve the result?
thanks
Use a linear layout with a height of fill_parent; set the center element to have a height of 0px and a layout_weight of 1; set the header/footer to wrap_content or give them a fixed height.
Basically, after fixed-height (or width, in the case of a horizontal LinearLayout) elements are allocated, the remaining space is divided proportionally by weight among the remaining children with weights assigned to them.