layout - Android: Positioning buttons when turned from portrait to landscape -
i have menu-activity, in have several positioned buttons. fits phone screen when in portrait mode, in landscape mode it's destroyed. know when have fixed positioning result. can tell me how position buttons activity keeps form in landscape mode? give thanks you.
here xml file:
<?xml version="1.0" encoding="utf-8"?> <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" android:orientation="vertical" > <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/bezpecnost_over" android:layout_marginleft="30dp" android:layout_margintop="50dp" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/kurenie_over" android:layout_marginleft="200dp" android:layout_margintop="50dp" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/osvetlenie_over" android:layout_marginleft="200dp" android:layout_margintop="200dp" android:onclick="obrosv" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/pohodlie_over" android:layout_marginleft="30dp" android:layout_margintop="200dp" /> </relativelayout>
it fits phone screen when in portrait mode, in landscape mode it's destroyed.
this expected relative-based layouts. developers in scenario:
make folder under res calledlayout-land
make xml same name layout in portrait mode (contained in res/layout
) position landscape mode. since xml file name same, when time activity set content view
setcontentview (r.layout.my_layout);
the my_layout.xml
file layout-land
folder used instead.
also read layouts & supporting multiple screens android docs, both have useful info latter talking different qualifiers (such layout-land
).
android layout button position
No comments:
Post a Comment