5

私は相対レイアウトを使用しており、添付の画像に示すように、TextView をボタンの下と中央に配置したいと考えています。BELOW を使用して一番下まで移動できますが、水平方向の中心を揃える方法がわかりません。

ここに画像の説明を入力

4

2 に答える 2

8

最も簡単な方法は、画像とテキストビューを相対的なレイアウトにすることです

 <RelativeLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:text="TextView" />

 </RelativeLayout>

編集

単一のレイアウトでこれを行うにはandroid:drawableTop 、TextView に追加します。

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" 
    android:drawableTop="@drawable/ic_launcher"/>
于 2013-07-31T11:53:25.173 に答える