如何将Android XML分为三个相等的布局矩形?

Spe*_*123 2 android-layout

如何将Android XML视图分成三个相等的布局矩形,如下图所示?

在此处输入图片说明

jos*_*hus 5

您要使用垂直的LinearLayout,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="3" >

    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:background="#ff0000" >
    </FrameLayout>
    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:background="#00ff00" >
    </FrameLayout>
    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:background="#0000ff" >
    </FrameLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)