Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Rotation Landscape Only

I'm writing an application for an Android Tablet. I want the ScreenOrientation always to be in "Landscape", but the app should be able to rotate 180°. If you hold the Tablet upside down, the View should be displayed correctly and rotate 180°.

Is there a simple way to do this? At the moment I'm forcing the app to be in landscape mode only within the Manifest I wrote android:screenOrientation="landscape" for the activity. But the rotation won't work like that.

like image 827
Nam Avatar asked Dec 23 '11 11:12

Nam


People also ask

How do I force orientation on Android?

Use Rotation Control to force screen orientation of Android devices. Once you've installed, open the app and just tap to turn it on. You can even start it when you restart your phone. This will help you when you don't want to open the again and again after every reboot.

How do I set Android apps to portrait only?

If you want to develop an application in portrait mode, add screenOrientation inside application tag. In the above result it is showing only portrait mode. now turn your device it not going to change the view according to orientation.


1 Answers

Use android:screenOrientation="sensorLandscape" instead.

Landscape orientation, but can be either normal or reverse landscape based on the device sensor. Added in API level 9.

See Dev Guide

Note that if you use android:configChanges="orientation" to avoid screen rotation in the activity tag, the screen will not rotate at all. If you want it to rotate only in landscape, use the option described above and remove the orientation flag. Check what is the behaviour you want before using this option or not.

like image 86
HandMadeOX Avatar answered Sep 18 '22 18:09

HandMadeOX