Is there a way to implement a working reusable border layout in android ? One that behaves just like swing's BorderLayout: Maximizing the middle and reducing the rest to minimal size ?
Try out this and you will get the same behaviour as Swings BorderLayout (the result is shown in the picture):
<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" />
You can use a RelativeLayout together with android:layout_weight attributes to get the same effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With