线性布局身高和体重 [英] Linear Layout Height and Weight

查看:128
本文介绍了线性布局身高和体重的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下

<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>

但布局不承担填补了高度妥善我想一个的LinearLayout的下方的另一个预期的效果,并采取了父空间的1/6。

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.

什么是假定Android的百分比高度正确的方法?宽度似乎与体重的微风,但我似乎无法得到它正确的高度。

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.

推荐答案

添加的android:方向=垂直的LinearLayout 因为默认情况下它是的android:方向=横向

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

这篇关于线性布局身高和体重的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆