线性布局高度和重量

Xav*_*ier 5 xml android android-layout android-linearlayout

我有以下内容

<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>
Run Code Online (Sandbox Code Playgroud)

然而,布局并不是假设正确地填充高度我希望一个linearLayout在另一个下面的期望效果并且占据父空间的1/6.

相反,它似乎是将重量应用于元素的宽度.

在Android中假设百分比高度的正确方法是什么?宽度似乎是轻微的重量,但我似乎无法在高度上得到正确.

Vin*_*kla 11

默认添加android:orientation="vertical"你的LinearLayoutas android:orientation="horizontal".