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 An example of RelativeLayout](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzR9KRxYsjw1y2FVQuZP7bNbXybBpFtkKvm3LNF_sJsHSsBWlHKFx1cWHCk7I904kDGCN2No_qk6mIhhMkg6IGbL0TGoq2B5vUw_qOOkylhJ055k6Yz8myQ7TISEcxVHa09rZIx0q4khBO/s400/RelativeLayout.png)
<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