Locking the orientation of my android phone
I开发者_Go百科'm writing an Android app. How do I lock the orientation of the phone in the portrait mode?
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">
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()
精彩评论