首页 > 解决方案 > 无论Android / React Native中的自动旋转如何将方向设置为纵向模式

问题描述

我想portrait mode在我的 react native android 应用程序中设置,我试图

  1. android:screenOrientation="portrait"在我的 AndroidManifest.xml文件中设置,
  2. 在我的活动中以编程方式添加方向,setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);但这些都不起作用。

注意:我已经react-native-navigation在我的项目中添加了

任何输入来解决这个问题?谢谢。

标签: androidreact-nativeuser-interfacereact-native-navigation

解决方案


如果你使用 react-native-navigation,试试这个

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

在此处查看文档。


推荐阅读