关于android:android-头中尾布局

9次阅读

共计 1342 个字符,预计需要花费 4 分钟才能阅读完成。

RelativeLayout

<RelativeLayout
            android:id="@+id/top"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:background="#f00">
    </RelativeLayout>
    <RelativeLayout
            android:id="@+id/center"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:layout_below="@id/top"
            android:layout_above="@+id/bottom"
            android:background="#00f">
    </RelativeLayout>
    <RelativeLayout
            android:id="@+id/bottom"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:layout_alignParentBottom="true"
            android:background="#0f0">
    </RelativeLayout>

LinearLayout

<!-- 头部布局 -->
    <LinearLayout android:layout_width="match_parent"
                  android:layout_height="50dp"
                  android:background="#f0f"/>


    <!-- 两头布局 -->
    <LinearLayout android:layout_width="match_parent"
                  android:layout_height="0dp"
                  android:layout_weight="1"
                  android:orientation="horizontal"
                  android:gravity="center"
                  android:background="#ff0">

        <Button android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="按钮一"
                android:layout_weight="1"/>
        <Button android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="按钮二"
                android:layout_weight="2"/>
        <Button android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="按钮三"
                android:layout_weight="1"/>

    </LinearLayout>

    <!-- 底部布局 -->
    <LinearLayout android:layout_width="match_parent"
                  android:layout_height="50dp"
                  android:background="#f00"/>

正文完
 0