0

コードは次のとおりです。

    <RelativeLayout
            android:id="@+id/top_lay2"
            android:layout_below="@id/top_lay1"
            android:layout_width="fill_parent"
            android:layout_marginTop="10dp"
            android:orientation="vertical"
            android:layout_height="wrap_content"
            android:background="@drawable/customrect">
<TextView
            android:layout_gravity="center"
            android:layout_width="fill_parent"
            android:layout_height="wrao_content"
            android:textColor="@color/white1"
            android:text="some text"
         />
<Button
            android:layout_gravity="center"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="click me"
    />

    </RelativeLayout>

そのxmlコードから、ビューが他のビューに対して垂直に表示されることを除いて、ビューは互いに積み重ねられます。ここで何が問題なのですか?

4

3 に答える 3

1

LinearLayout では、フィールドは垂直に表示されます。ただし、RelativeLayout では、互いの相対的な位置を指定する必要があります。したがって、「RelativeLayout」を「LinearLayout」に置き換えれば、準備は完了です。

于 2012-09-19T19:38:46.020 に答える
0

orientation="vertical"RelativeLayoutを代わりに使用したり、と のLinearLayout間に適切な関係を定義したりすることはサポートされていません。TextViewButton

http://developer.android.com/guide/topics/ui/layout/linear.htmlもチェックし てください

于 2012-09-19T19:37:59.547 に答える
0

RelativeLayout RelativeLayout は、互いに対する子の位置を記述する必要があります。

配置を自動的に行いたい場合は、向きを垂直に設定したLinearLayoutを使用します。

于 2012-09-19T19:37:31.760 に答える