Linear height and weight of the layout

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 do not propose to properly fill the height, I want one linearLayout below the other for the desired effect and take up 1 / 6th of the parent space.

Instead, it seems to apply weight to the width of the element.

What is the correct method for determining percent height in Android? Width seems to be a breeze with weight, but I cannot understand how correct it is in height.

+5
source share
1 answer

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

+11
source

All Articles