2

下の画像のように、Android XML ビューを 3 つの等しいレイアウトの長方形に分割するにはどうすればよいですか?

ここに画像の説明を入力

4

2 に答える 2

5

You want to use a vertical LinearLayout, like this:

<?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>
于 2013-07-22T03:43:33.527 に答える
0

この場合、linear-layout をorientation:Vertical

これを試してください

<?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="fill_parent"
android:orientation="vertical" >

<Button
    android:id="@+id/button2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0.17"
    android:text="Button" />

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="114dp"
    android:layout_weight="0.11"
    android:text="Button" />

<Button
    android:id="@+id/button3"
    android:layout_width="334dp"
    android:layout_height="wrap_content"
    android:layout_weight="0.17"
    android:text="Button" />

 </LinearLayout>
于 2013-07-22T03:25:59.380 に答える