开发者

Lock Horizontal View

I want to lock horizontal view in my app, is it possible?

Help is high开发者_Python百科ly appreciated,

Thanks,


Use android:screenOrientation="landscape" attribute for your activity.


add this code in your menifest...

<activity android:name=".activity"
        android:configChanges="orientation"   android:screenOrientation="portrait"></activity>


For new android Studio 3 and above you need to put these lines in AndroidManifest.xml code if you want to set the orientation to portrait

One thing this is sensor portrait, means both upside - downside will work.

But if you only want to put portrait for upside then, replace sensorPortrait to portrait

<activity
            android:name=".MainActivity"
            android:configChanges="orientation"
            android:screenOrientation="sensorPortrait"
            tools:ignore="LockedOrientationActivity">

Same goes for only landscape too just one parameter change portrait to landscape

<activity
            android:name=".MainActivity"
            android:configChanges="orientation"
            android:screenOrientation= "sensorLandscape"
            tools:ignore="LockedOrientationActivity">
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜