I have a relative layout with several buttons in it.When auto rotate happens all buttons get overlapped.how can i avoid that so that all the controls remain intact on auto rotate??
Any help would be really appreciated.
Thanks
I have a relative layout with several buttons in it.When auto rotate happens all buttons get overlapped.how can i avoid that so that all the controls remain intact on auto rotate??
Any help would be really appreciated.
Thanks
you should align view with respect to other views to avoid overlapping .. using android:layout_below
, android:layout_toRightOf
etc properties..
Something like this..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:layout_marginTop="20dp"
android:text="Button1" />
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button2"
android:layout_marginTop="20dp">
</EditText>
</RelativeLayout>
you should use some fixed points in your relative view to align your buttons on it, for example if you have four buttons two on top and two below them: and you align the two lower buttons one right_of button 1 and the second at the baseline_end, they will be overlapped in one view or another: it's better to choose to align buttons in the same way :
in this example i will stack the two upper buttons (button 1 and 2) by aligning them on ParentRight and Parentleft as a reference, and the two lower buttons (button 3 and 4) by aligning right and left to buttons 1 and 2 and not by mixing the one to each other:
choose to align all your buttons on fixed points in your layout or all of them relatively to each other (but at least you must have one on a fixed point), and do not align the lowest to a fixed reference in your layout i hope that i clearly explained my answer