开发者

Locking the orientation of my android phone

开发者 https://www.devze.com 2023-03-19 04:40 出处:网络
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 th

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

精彩评论

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