-1

以下のようにボタンを配置したレイアウトを作成したいと思います。このようなレイアウトを作成する方法を教えてください。

-----------------------------------
|  b1  |  b2 |  b3  |  b4  |  b5  |
-----------------------------------





--------                   --------
|  b6  |                   |  b7  |
--------                   --------





--------------------------------------
|  b8  |  b9 |  b10  |  b11  |  b12  |
--------------------------------------
4

1 に答える 1

0

このようなことを試すことができます。中央の RelativeLayout は必要ありません。android:layout_centerInParent="true" プロパティを 2 つのボタンに追加して、RelativeLayout をそのままにしておくことができます。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layoutBase"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="3" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

    </LinearLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" >
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:text="Button" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="Button" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="3"
        android:layout_alignParentBottom="true" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

    </LinearLayout>

</RelativeLayout>

同様の目的のために、IDE のグラフィカル レイアウト デザイナも良い出発点です。

それが役立つことを願っています!

于 2012-12-30T17:39:18.720 に答える