现在的位置: 首页 > 综合 > 正文

android layout_weigh用法

2017年01月08日 ⁄ 综合 ⁄ 共 857字 ⁄ 字号 评论关闭

传说中的布局3等分:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"

        android:background="#f00"
        android:gravity="center"
        android:text="Hello World,1" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"

        android:background="#00f"
        android:gravity="center"
        android:text="Hello World, 2" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"

        android:background="#0f0"
        android:gravity="center"
        android:text="Hello World, 3" />

</LinearLayout>

运行效果:

抱歉!评论已关闭.