0

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?

4 Answers4

1

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.

Community
  • 1
  • 1
Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
0

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.

davidcesarino
  • 16,160
  • 16
  • 68
  • 109
Chitranshu Asthana
  • 1,089
  • 8
  • 19
0

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.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Maidul
  • 1,289
  • 16
  • 30
-1

Place to allactivities android:screenOrientation="portrait" in manifest like:

 <activity android:name=".View" android:screenOrientation="portrait"
            android:label="Home">
        </activity>
PedroAGSantos
  • 2,336
  • 2
  • 17
  • 34