Reputation: 161
I'm writing an Android app. How do I lock the orientation of the phone in the portrait mode?
Upvotes: 0
Views: 1446
Reputation: 103
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()
Upvotes: 0
Reputation: 167
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">
Upvotes: 1