BorderLayout в андроиде? - PullRequest
       9

BorderLayout в андроиде?

3 голосов
/ 24 июня 2011

Есть ли способ реализовать работающий многократно используемый макет границы в Android?Тот, который ведет себя как свинг BorderLayout: максимизация середины и уменьшение остальных до минимального размера?

Ответы [ 2 ]

6 голосов
/ 07 апреля 2015

Попробуйте это, и вы получите то же поведение, что и Swings 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" />

1 голос
/ 25 июня 2011

Вы можете использовать RelativeLayout вместе с android:layout_weight атрибутами, чтобы получить тот же эффект.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...