views:

801

answers:

2

I have a vertical, set height (300px) LinearLayout (LL) with 3 nested LLs. 1 and 3rd are set with android:layout_height="wrap_content" and the middle one with android:layout_height="fill_parent". To my dismay, 3rd LL gets pushed out with 2nd one filling parent layout right to the bottom. How do I achieve desired effect since I want potentially resize the outside container with the middle portion expanding and contracting to accommodate the change

A: 

You could create the following layout hierarchy (and set top and bottom to fixed heights):

<LinearLayout
    android:id="@+id/top"
    android:layout_height="wrap_content"/>
<LinearLayout
    android:layout_height="fill_parent">
   <LinearLayout
       android:id="@+id/center"
       android:layout_height="fill_parent"/>
   <LinearLayout
       android:id="@+id/bottom"
       android:layout_height="wrap_content"/>
</LinearLayout>
Josef
+2  A: 

Turned out (Thanks Mark Murphy for the answer) that all I was looking for was to set middle row to

layout_height="0px" and layout_weight="1"

DroidIn.net
thanks a lot, worked out well
Amith GC