Home > other >  Android portrait screen orientation doesn't work [React Native]
Android portrait screen orientation doesn't work [React Native]

Time:12-30

Hi I'm working on a react-native app and when I try to set the Android screen orietnation exclusively to portrait, it doesn't work, here's project specs:

RNNKotlinVersion = "1.6.0"
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33

And here's my code in AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"

    <application
      tools:ignore="LockedOrientationActivity"

      <activity
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustPan"

What's wrong with this code? thank you

CodePudding user response:

Try to use this package https://github.com/wonday/react-native-orientation-locker

It works perfectly and allows you to control orientation from JS side.

import Orientation from 'react-native-orientation-locker';

...

Orientation.lockToPortrait();

...

  • Related