安卓线性布局LinearLayout

image
1、weight权重解读
用法归纳: 按比例划分水平方向:将涉及到的View的android:width属性设置为0dp,然后设置为android weight属性设置比例即可。
`

<LinearLayout
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:background="#ADFF2F"
    android:layout_width="0dp"></LinearLayout>

<LinearLayout
    android:layout_height="match_parent"
    android:layout_weight="2"
    android:background="#DA70D6"
    android:layout_width="0dp"></LinearLayout>

<LinearLayout
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:background="#DF0D5"
    android:layout_width="0dp"></LinearLayout> 

`
按比例划分垂直方向,将父控件 android:orientation="vertical" 。子控件 android:layout_height="0dp" ,然后设置为android weight属性设置比例即可。

原文地址:https://www.cnblogs.com/caoruipeng/p/15646115.html