I use two different layout folders:
layout
layout-large
Now I want to ensure that the screen orientation is portrait if the layout
folder is used, and landscape if the layout-large
folder is used. How can I force this?
I use two different layout folders:
layout
layout-large
Now I want to ensure that the screen orientation is portrait if the layout
folder is used, and landscape if the layout-large
folder is used. How can I force this?
The correct directory-name for the landscape layouts is 'layout-land', see here.
If you do this, you don't need to do other things, Android will do the rest for you.
If you want to change to landscape based on the size of the Screen, you can check for the screen-resolution and then set the Orientation using the 'setRequestedOrientation()'-method from the Activity class.
Maybe its too late.. But for what it's worth, you can define orientation in value for small screen and in value-large for large screen and then use it in AndroidManifest.xml
.
Have a look at my blog post.
Please have a look at this
supports-screens
android:resizeable=["true"| "false"]
android:smallScreens=["true" | "false"]
android:normalScreens=["true" | "false"]
android:largeScreens=["true" | "false"]
android:xlargeScreens=["true" | "false"]
android:anyDensity=["true" | "false"]
android:requiresSmallestWidthDp="integer"
android:compatibleWidthLimitDp="integer"
android:largestWidthLimitDp="integer
It will handle your screen.
Place to allactivities android:screenOrientation="portrait"
in manifest like:
<activity android:name=".View" android:screenOrientation="portrait"
android:label="Home">
</activity>