Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linear Layout Height and Weight

I have the following

<linearLayout>
<RelativeLayout>
    <!-- Header -->
</RelativeLayout>

<linearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="6">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
    </LinearLayout>

</linearLayout>

However the layouts are not assuming to fill the height properly I wish to for the desired effect of one linearLayout below another and to take up 1/6th of the parent space.

Instead it seems to be applying the weight to the width of the element.

What is the correct method to assume percentage height in Android? Width seems to be a breeze with Weight but I can't seem to get it correct on Height.

like image 306
Xavier Avatar asked Jun 01 '12 08:06

Xavier


1 Answers

add android:orientation="vertical" in your LinearLayout as by default it is android:orientation="horizontal".

like image 166
Vineet Shukla Avatar answered Nov 02 '22 08:11

Vineet Shukla