I'm writing an Android app. How do I lock the orientation of the phone in the portrait mode?
Asked
Active
Viewed 1,441 times
0
-
take a look at http://stackoverflow.com/questions/1512045/how-to-disable-orientation-change-in-android – Bobby Jul 09 '11 at 03:05
2 Answers
1
In your AndroidManifest.xml
add the following tag android:screenOrientation="portrait"
in the Activity block. A sample would be:
<activity android:name=".FusionDrone"
android:label="@string/app_name"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent">

Matt Pope
- 167
- 2
- 11
0
the android:screenOrientation="portrait"
would be the way to go but if you want to do it programmatically, just call setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
in your onCreate()

JM Macariola
- 103
- 1
- 4