Reputation: 8016
I am trying to lock orientation for cordova android app to landscape using
<preference name="Orientation" value="landscape" />
This works fine it loads app in landscape view. But when I flip the emulator vertically(upside down - 180degree) the screen remains fixed and does flips the view vertically. I want to show in landscape mode only even if user rotates the device to 180 degrees.
Using cordova-android: 7.0.0
Any suggestions?
Upvotes: 0
Views: 601
Reputation: 196
Please use this for unlock(both mode) for
screen.orientation.unlock();
and use screen lock portrait mode
screen.orientation.lock('portrait');
Upvotes: 1
Reputation: 8016
I have found a solution to this, without using any plugin. We can put configuration in config.xml to modify AndroidManifest.xml at build time.
Put the following in config.xml
<edit-config file="AndroidManifest.xml" target="/manifest/application/activity[@android:name='MainActivity']" mode="merge">
<activity android:name="MainActivity" android:screenOrientation="userLandscape" />
</edit-config>
Also add following in the <widget>
tag of config.xml
xmlns:android="schemas.android.com/apk/res/android"
Following are possible values for the screenOrientation
field
screenOrientation (attr) enum [behind=3, fullSensor=10, fullUser=13,
landscape=0, locked=14, nosensor=5, portrait=1, reverseLandscape=8,
reversePortrait=9, sensor=4, sensorLandscape=6, sensorPortrait=7,
unspecified=4294967295, user=2, userLandscape=11, userPortrait=12]
Upvotes: 1