How to change layout position when changing screen orientation in Android?

How to change the position of the layout when changing the screen orientation in android?

I have a button in Relativelayout.

When the phone LANDSCAPE, Relativelayoutat the bottom.

And he turns to the right of the screen when the phone PORTRAIT.

This is similar to the following image.

I get the orientation of the screen, but how to set Relativelayoutto change its position from bottom to right?

enter image description here

---------------------------------- EDIT ------------ --- -------------

Code xmlc layout-land.

In top_buttonlayout1there are two button, the other two buttonare in bottom_buttonlayout1.

top_buttonlayout1- this is Relative-2in the picture, and bottom_buttonlayout1- the bottom one Relativelayout.

And I want it to change directly, how to do it?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:baselineAligned="false"
    android:orientation="vertical" >


    <LinearLayout
        android:id="@+id/top_buttonlayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/top_buttonlayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:background="#00000000" >

           <ImageButton
                android:id="@+id/SettingButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="fitXY"
                android:layout_marginTop="5dp"
                android:background="#00000000"
                android:src="@drawable/parmeter_setting" />

            <ImageButton
                android:id="@+id/FileSavebutton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="fitXY"
                android:layout_marginTop="5dp"
                android:layout_marginRight="5dp"  
                android:background="#00000000"        
                android:src="@drawable/save_in_camera" />

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/bottom_buttonlayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="vertical"
        android:background="#454749"
         >

       <RelativeLayout
            android:id="@+id/bottom_buttonlayout"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">


            <ImageButton
                android:id="@+id/FileButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:scaleType="fitXY"
                android:layout_centerVertical="true"
                android:background="#454749"
                android:src="@drawable/file_viewer"/>

             <ImageButton
                android:id="@+id/photo_record_mode"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="20dp"
                android:layout_alignParentRight="true"  
                android:layout_centerVertical="true"            
                android:scaleType="fitXY"
                android:background="#454749"
                android:src="@drawable/recordmode"/>

        </RelativeLayout>
    </LinearLayout>

</RelativeLayout>
+4
3

xml layout-port layout-land folder res.

:

res/layout-land [Landscape Mode]
main.xml 
res/layout-port [Portrait Mode ]
main.xml

http://developer.android.com/training/basics/supporting-devices/screens.html

:

+5

lanscape layout-land

+2

xml layout layout-land res.

somthing like:

res/layout-land [Landscape Mode]
main.xml 
res/layout [Portrait Mode ]
main.xml

. : http://developer.android.com/training/basics/supporting-devices/screens.html

+1
source

All Articles