Lock Horizontal View
I want to lock horizontal view in my app, is it possible? Help is highly appreciated, Thanks,
Solution 1:
Use android:screenOrientation="landscape"
attribute for your activity.
Solution 2:
add this code in your menifest...
<activityandroid:name=".activity"android:configChanges="orientation"android:screenOrientation="portrait"></activity>
Solution 3:
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
<activityandroid:name=".MainActivity"android:configChanges="orientation"android:screenOrientation="sensorPortrait"tools:ignore="LockedOrientationActivity">
Same goes for only landscape too just one parameter change portrait to landscape
<activityandroid:name=".MainActivity"android:configChanges="orientation"android:screenOrientation= "sensorLandscape"tools:ignore="LockedOrientationActivity">
Post a Comment for "Lock Horizontal View"