0

TV2 が TV1 に対して相対的であり、TV1 と TV2 がレイアウトの異なるブランチ内にある場合、このようなことを行うことは可能ですか?

<?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="fill_parent" >

    <RelativeLayout
        android:id="@+id/RV1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/TV01"
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:text="test text" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/RV2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/RV1" >

        <TextView
            android:id="@+id/TV02"
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:layout_toRightOf="@+id/TV01"  <--------- this references TV01 within the top RelativeView !!!
            android:text="other text" />
    </RelativeLayout>

</RelativeLayout>

この例では、は別の RealtiveLayout ブランチ内android:layout_toRightOf="@+id/TV01"にあるため、ステートメントは機能していないようです。TV01TV02

どういうわけかこのような参照を作成する方法はありますか?

どうもありがとう!

4

2 に答える 2

3

いいえ、そのような RelativeLayout の配置は使用できません。でも:

  • 組み合わせることができRV1RV2

また

  • RV2の右側に配置できますRV1
于 2012-07-15T16:41:21.247 に答える
1

これは簡単な例ですか?またはこれはあなたの実際のレイアウトです。後者の場合、rel2 を次のように変更することで、同じ効果を達成できるはずです。

<RelativeLayout
    android:id="@+id/RV2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/RV1"
    android:layout_toRightOf="@+id/RV1" >
于 2012-07-15T16:40:40.420 に答える