开发者

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜