tags:

views:

60

answers:

3

hello

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

A: 

Did you tried FILL_PARENT?

FILL_PARENT, which means the view wants to be as big as its parent (minus padding)

Check this link.

Macarse
doesnt work cuz this way the footer is pushed out of the screen :(
nourdine
+1  A: 

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.

Yoni Samlan
A: 

use a RelativeLayout as the root. For the footer set android:layout_alignParentBottom="true" in the xml and for the header set android:layout_alignParentTop="true" then set the middle to fill_parent and layout_above = your_footer as well as layout_below = your_header

jqpubliq