2011-06-24 7 views

答えて

1

同じ効果を得るには、RelativeLayoutandroid:layout_weightの属性を併用できます。

+0

RUは確か属性が「layout_weightを"? (Android 2.1 APIレベル7) – Bigbohne

+0

@Bigbohne - [R.attrのドキュメント](http://developer.android.com/reference/android/R.attr.html#layout_weight)から: "public static final int * * layout_weight ** Since:APIレベル1 "名前空間修飾子 'android:'は必須であることに注意してください。 'layout_weight'という属性はありませんが、' android:layout_weight'という属性が1つあります。 –

3

これを試してみてください、あなたはスイングのBorderLayout(結果は画像内に示す)と同じ動作を取得します:

BorderLayout Demo

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

<TextView 
    android:id="@+id/north" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:background="@android:color/holo_orange_light" 
    android:gravity="center_horizontal" 
    android:text="North" 
    android:textAppearance="@android:style/TextAppearance.Large" /> 

<TextView 
    android:id="@+id/south" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:background="@android:color/holo_blue_light" 
    android:gravity="center_horizontal" 
    android:text="South" 
    android:textAppearance="@android:style/TextAppearance.Large" /> 

<TextView 
    android:id="@+id/west" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:layout_above="@id/south" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@id/north" 
    android:background="@android:color/holo_red_light" 
    android:gravity="center_vertical" 
    android:text="West" 
    android:textAppearance="@android:style/TextAppearance.Large" /> 

<TextView 
    android:id="@+id/east" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:layout_above="@id/south" 
    android:layout_alignParentRight="true" 
    android:layout_below="@id/north" 
    android:background="@android:color/holo_purple" 
    android:gravity="center_vertical" 
    android:text="East" 
    android:textAppearance="@android:style/TextAppearance.Large" /> 

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_above="@id/south" 
    android:layout_below="@id/north" 
    android:layout_toLeftOf="@id/east" 
    android:layout_toRightOf="@id/west" 
    android:background="@android:color/holo_green_light" 
    android:gravity="center" 
    android:text="Center" 
    android:textAppearance="@android:style/TextAppearance.Large" /> 

関連する問題