我无法获得如下所示的布局:



是否可以做这样的事情:

<RelativeLayout>

    <TextView
    android:id="@+id/text1"
    android:layout_alignParentLeft="true"/>

    <TextView
    android:layout_below="@id/text1/>

    <LinearLayout
    android:orientation="vertical"
    android:layout_alignRightOf="@id/text1">

        <ImageButton/>
        <ImageButton/>
        <ImageButton/>

    </LinearLayout>

</RelativeLayout>


更具体地说,是否可以在上设置layout_align,如下所示:android:layout_alignRightOf="@id/text1"

如果没有,如何获得此布局?

最佳答案

我不知道如何(如果可能)使用RelativeLayout进行此操作,但是使用一些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="horizontal" >

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="#ff0000"
        android:orientation="vertical" >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="#aa0000ff"
            android:layout_weight="1" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="#aaff0000"
            android:layout_weight="1" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:background="#00ff00"
        android:orientation="vertical" >

        <ImageButton
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <ImageButton
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <ImageButton
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />
    </LinearLayout>

</LinearLayout>

09-10 06:55
查看更多