Is any chance to disable screen rotation (allow only vertical)? I would like to support only portrait view. And need it to work on android and ios.
7 Answers
In android :-
using xml :-android:screenOrientation="portrait"
using java :-
@Override
public void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
1 Comment
Rajan Maharjan
Please be clear with your answer, also the question is for both iOs and Android.
Have a look at Android's official documentation
You just have to add this to your activity tag in your android MANIFEST file :
<activity
android:screenOrientation=["unspecified" | "behind" |
"landscape" | "portrait" |
"reverseLandscape" | "reversePortrait" |
"sensorLandscape" | "sensorPortrait" |
"userLandscape" | "userPortrait" |
"sensor" | "fullSensor" | "nosensor" |
"user" | "fullUser" | "locked"]
using the orientation that you want.
Comments
Try to add this in config.xml
<preference name="Orientation" value="landscape" />
1 Comment
tschoffelen
This applies to Cordova/Phonegap, not React Native.
app.jsonfile to setorientationas either potrait or landscape. See here for more details: docs.expo.io/versions/latest/workflow/…