9

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.

4

7 Answers 7

8

Add screenOrientation in your Manifest.xml class

<activity android:name=".YourActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" />
Sign up to request clarification or add additional context in comments.

Comments

2

Put the below code in manifest file

<activity
   android:screenOrientation="portrait"
   android:configChanges="orientation|keyboardHidden">
</activity>

Comments

2

Write the below code in manifest file

<activity
   android:screenOrientation="portrait"
   android:configChanges="orientation|screenSize">
</activity>

Comments

1

In android :-

using xml :-android:screenOrientation="portrait"

using java :-

@Override 
public void onCreate(Bundle savedInstanceState) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

1 Comment

Please be clear with your answer, also the question is for both iOs and Android.
1

Winner: chuck this in the app code, I usually drop it right after all my imports.

Expo.ScreenOrientation.allow(Expo.ScreenOrientation.Orientation.PORTRAIT);

Comments

0

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

-1

Try to add this in config.xml

<preference name="Orientation" value="landscape" />

1 Comment

This applies to Cordova/Phonegap, not React Native.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.