Wednesday, 22 June 2011

A example of RelativeLayout, layout_alignParentTop, layout_alignParentBottom and layout_above

It's a example of using RelativeLayout; place a button (or any other view) on top of screen, a button on bottom of screen, and another button place related to another view.

A example of RelativeLayout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Button on Top"
/>
<Button
android:id="@+id/buttonOnBottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Button on Bottom"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/buttonOnBottom"
android:text="Button Above Button on Bottom"
/>
</RelativeLayout>
</LinearLayout>


Borneo08

About Borneo08

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :

More links

Related Posts Plugin for WordPress, Blogger...