An example of RelativeLayout

An example of XML using RelativeLayout, two buttons are placed on both left and right, and the last button is placed on the center position.

An example of RelativeLayout

<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/leftbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Left"
android:layout_alignParentLeft="true"
/>
<RelativeLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/leftbutton"
>
<Button
android:id="@+id/rightbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Right"
android:layout_alignParentRight="true"
/>
<Button
android:id="@+id/centerbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/rightbutton"
android:text="Center Button"
/>
</RelativeLayout>
</RelativeLayout>


0 Response to "An example of RelativeLayout"

Posting Komentar