简体   繁体   English

如何将方向设置为纵向模式,而不管 Android / React Native 中的自动旋转

[英]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我想在我的本机 android 应用程序中设置portrait mode ,我试图

  1. set android:screenOrientation="portrait" in my Android Manifest.xml file,在我的 Android Manifest.xml文件中设置android:screenOrientation="portrait"
  2. adding orientation programmatically in my activity as setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);在我的活动中以编程方式添加方向作为setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); but none of these is working.但这些都不起作用。

Note: I have added react-native-navigation in my project注意:我在我的项目中添加了react-native-navigation

Any inputs to resolve this?任何输入来解决这个问题? Thanks.谢谢。

if you're using react-native-navigation, try this如果你使用的是 react-native-navigation,试试这个

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

Check the docs here .检查这里的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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