Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Multi Orientation - Android

I'm new at android programming and I've got a problem with orientation.

I want my activities only to be viewable in the portrait and reverse-portrait and orientations.

I thought android:screenOrientation="portrait|reversePortrait" would work but it is not working. Is there have any way to do this in the manifest file?

like image 945
tokiyashi Avatar asked Sep 02 '12 18:09

tokiyashi


People also ask

How do I manage different orientations in Android?

If you want to manually handle orientation changes in your app you must declare the "orientation" , "screenSize" , and "screenLayout" values in the android:configChanges attributes. You can declare multiple configuration values in the attribute by separating them with a pipe | character.

How do I manage portrait and landscape on Android?

Rotate your phone to change the screen orientation (if Auto Rotate is enabled). If Auto Rotate is enabled, your phone's screen will automatically flip to portrait mode when you are holding it upright. When you are holding it horizontally, it will automatically switch to Landscape mode.

What are the orientation modes available in Android?

As with almost all smartphones, Android supports two screen orientations: portrait and landscape. When the screen orientation of an Android device is changed, the current activity being displayed is destroyed and re-created automatically to redraw its content in the new orientation.


1 Answers

Please check the documentation: http://developer.android.com/guide/topics/manifest/activity-element.html#screen

In API 9+ added that portrait orientation, but can be either normal or reverse portrait based on the device sensor. So you can use android:screenOrientation="sensorPortrait" for both.

like image 53
Marcin S. Avatar answered Oct 18 '22 04:10

Marcin S.