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.

<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>
couldn't you put all 3 of the in 1 RLayout? why 2 of them>
ReplyDeleteThis can also be done using one RLayout...
ReplyDeletethis can be made with only one RelativeLayout, using
ReplyDeleteandroid:layout_centerHorizontal="true" in the middle one