2 つのオプションが表示されます。
オプション 1、ネストなし (この方法では、バーはレイアウトの上部にありますが、レイアウトの使用に適している場合は、上部マージンを設定して少し下げることができます):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/bigfoo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:text="bigfoo"
android:textSize="60sp"/>
<TextView
android:id="@+id/foo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/bigfoo"
android:layout_centerVertical="true"
android:text="foo"/>
<TextView
android:id="@+id/bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/bigfoo"
android:text="bar"/>
</RelativeLayout>
オプション 2、最初の RelativeLayout に別の RelativeLayout をネストする:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/bigfoo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="bigfoo"
android:textSize="60sp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/bigfoo"
android:layout_alignBottom="@id/bigfoo"
android:orientation="vertical"
android:layout_toRightOf="@id/bigfoo">
<TextView
android:id="@+id/foo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="foo" />
<TextView
android:id="@+id/bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/foo"
android:text="bar" />
</RelativeLayout>
</RelativeLayout>
オプション 2 を使用すると、期待どおりの結果が得られるはずですが、別のレイアウト内にレイアウトをネストするという犠牲が伴います。UI の残りの部分が軽い場合、問題にはなりません ;)
編集:これを試していただけますか?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/bigfoo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:text="bigfoo"
android:textSize="60sp"/>
<TextView
android:id="@+id/foo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/bigfoo"
android:layout_centerVertical="true"
android:text="foo"/>
<TextView
android:id="@+id/bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/foo"
android:layout_alignLeft="@id/foo"
android:text="bar"/>
</RelativeLayout>
これが私が見ているものですが、これが機能する理由を説明するのは難しいでしょう...
