如何将布局分为3个部分? [英] How to divide layout to 3 parts?

查看:73
本文介绍了如何将布局分为3个部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将布局划分为3个相等的行,尝试使用LinearLayout和权重,但是它不起作用,也没有任何改变:

I'm trying to divide my layout to 3 equal rows, trying to use LinearLayout and weights, but it doesn't work, it doesn't make any change:

<LinearLayout
    android:id="@+id/rightLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignBottom="@+id/picture"
    android:layout_alignParentRight="true"
    android:layout_alignTop="@+id/picture"
    android:layout_toRightOf="@+id/aligner"
    android:orientation="vertical"
    android:weightSum="3" >

    <LinearLayout
        android:id="@+id/lay1"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#00ff00" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/lay2"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/TextView01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/lay3"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/TextView02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />
    </LinearLayout>

</LinearLayout>

推荐答案

起初,我没有意识到,这个问题并不存在.我有ScrollView,它使这些布局无法使用权​​重.我在ScrollView中添加了android:fillViewport="true",它已修复.

At first, I didn't realise, that problem was not there. I had ScrollView and it made these layouts not work with weights. I added android:fillViewport="true" to ScrollView and it got fixed.

这篇关于如何将布局分为3个部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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