How to set the orientation in two different modes, in two layouts?

I have a layout called Main.XML and I set the portrait orientation in my AndroidManifest.xml . I also designed this layout for Honeycomb and put it in the layout-xlarge-mdpi , but I want to use Main.XML in layout-xlarge-mdpi only in landscape orientation.

Now how to do it?

thanks

0
source share
4 answers

You can put your main.xml in layout-xlarge-land , then it will only be used in landscape orientation
Consult Multi-Screen Support (using configuration specifiers)

Android supports several configuration qualifiers that allow you to control how the system selects alternative resources based on the characteristics of the current screen device. The configuration specifier is a line that you can add to the resource directory on your Android device of the project and determines the configuration for which the resources are inside.

Edit: If you provided main.xml in the layout folder and another main.xml in layout-xlarge-land , then

  • for extra large landscape orientation it will take the value main.xml from layout-xlarge-land

  • for all other, that is in landscape or portrait orientation will need main.xml from layout

See Providing alternative resources for more information.

+5
source

Create a layout-xlarge-mdpi-land folder and put main.xml in this

+2
source

I think this can be done as follows:

Not sure if this is the best way.

+1
source

In AndroidManifest, paste the following code depending on the activity that you want to work in landscape mode (in this case, the Main activity)

 android:screenOrientation="landscape" 
+1
source

All Articles