简体   繁体   中英

How to set orientation to portrait mode, regardless the auto-rotate in Android / React Native

I want to set portrait mode in my react native android application, I tried to

  1. set android:screenOrientation="portrait" in my Android Manifest.xml file,
  2. adding orientation programmatically in my activity as setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); but none of these is working.

Note: I have added react-native-navigation in my project

Any inputs to resolve this? Thanks.

if you're using react-native-navigation, try this

Navigation.setDefaultOptions({
layout: {
    orientation: ["portrait"],
},
});

Check the docs here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM