LinearLayout中使每个子控件均匀布局

要想使LinearLayout布局中的每个子控件自动设置为相同大小,并均匀分布,可以在布局文件中设置layout_weight参数的值一致。

示例代码如下:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/txt_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>

    <TextView
        android:id="@+id/txt_2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>

</LinearLayout>


猜你喜欢

转载自blog.csdn.net/chenzhengfeng/article/details/78478043
今日推荐