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.
Main.XML
AndroidManifest.xml
layout-xlarge-mdpi
Now how to do it?
thanks
You can put your main.xml in layout-xlarge-land , then it will only be used in landscape orientationConsult Multi-Screen Support (using configuration specifiers)
main.xml
layout-xlarge-land
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
layout
for extra large landscape orientation it will take the value main.xml from layout-xlarge-land
extra large landscape orientation
main.xml from layout-xlarge-land
for all other, that is in landscape or portrait orientation will need main.xml from layout
all other, that is in landscape or portrait orientation
main.xml from layout
See Providing alternative resources for more information.
Create a layout-xlarge-mdpi-land folder and put main.xml in this
layout-xlarge-mdpi-land
I think this can be done as follows:
Determine the screen size programmatically in you. http://www.mail-archive.com/ android-developers@googlegroups.com /msg144381.html
Set the orientation according to the screen size, for example:
if (screen size is large) setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); another setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Not sure if this is the best way.
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"