0

RelativeLayout、「textA」、「textB」、および「textC」で3つのTextViewを宣言すると。textC は textB の下に表示されます。しかし、実行すると、textC が不適切な位置 (画面の左上) に表示されます。textC が android:layout_below を textB に使用できるかどうかはわかりません。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent" >
    <TextView
        android:id="@+id/textA"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:text="This is TextA : " />
    <TextView
        android:id="@+id/textB"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/textA"
        android:layout_alignBaseline="@id/textA"
        android:text="this is textB" />
    <TextView
        android:id="@+id/textC"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/textB"
        android:text="This is TextC" />
</RelativeLayout>
4

3 に答える 3

2

変更することもできます

android:layout_below="@id/textA"

テキストCへ

完全な例は次のようになります。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent" android:layout_height="match_parent" >
<TextView
    android:id="@+id/textA"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:text="This is TextA : " />
<TextView
    android:id="@+id/textB"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/textA"
    android:layout_alignBaseline="@+id/textA"
    android:text="this is textB" />
<TextView
    android:id="@+id/textC"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textB"
    android:layout_below="@+id/textA"
    android:text="This is TextC" />

于 2013-01-06T16:13:27.733 に答える
0

他の要素に対して alignBaseline を使用する要素に対して垂直方向の配置を使用することはできません。次に、この場合、「textB」で、コードのように alignBaseline を alignTop に変更します。

<TextView
    android:id="@+id/textB"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/textA"
    android:layout_alignTop="@id/textA"
    android:text="this is textB" />

この方法を使用すると、textB の複数行がサポートされます。

于 2013-01-07T13:38:52.660 に答える
0

以下の変更を行うだけですTextView3

 <TextView
    android:id="@+id/textC"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/textB" 
    android:layout_below="@+id/textA"
    android:text="This is TextC" />
于 2013-01-06T16:09:18.673 に答える