May i know how do i align the Button just beside these three Textviews? Instead of just below the Textviews.
This is the XML file.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:id="@+id/linearlayout1"
android:background="#000000">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/textview1"
android:layout_alignParentLeft="true" android:text="Textview1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Textview2"
android:layout_alignParentLeft="true" android:id="@+id/Textview2" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentLeft="true"
android:text="Textview3" android:id="@+id/Textview3" />
<RelativeLayout android:id="@+id/relativeLayout2"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<Button android:id="@+id/button" android:layout_width="70px"
android:layout_height="38px" android:text="Button"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
IMO you should put the three textviews and the button in the RelativeLayout, and get rid of the LinearLayout. There’s no point in having two layouts when you can get by with just one, as each ViewGroup adds overhead to the layout and draw passes. Do:
I didn’t compile this, but it should do what you need. Play around with the layout parameters you give button (you can align it to the top and right of the parent, or to the right of any of the textboxes, etc…).
The RelativeLayout is very powerful; you should really take advantage of it’s flexibility.