本文介绍了React-native Android Set only Portrait Mobile Phones 否则平板显示landScape和Portrait的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这种情况下,我在我的应用程序中遇到了一个小问题,我设置了默认的纵向.但现在我想在选项卡中显示纵向和横向,而不仅仅是手机.在手机中仅显示纵向(强制更新为纵向).

我点击了这个链接,但我收到了这个错误,我不明白我们如何创建可以放置数据的文件夹.我点击了这个链接:但我没有得到

2.在android/app/src/main/java/com/[您的项目名称]/MainActivity.java

路径下添加代码到MainActivity.java

@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);如果(getResources().getBoolean(R.bool.portrait_only)){setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);}}

I have a small problem in this case in my app I set default Portrait.But now this time i want show Portrait and landScape in Tabs not only Mobile phone .In mobile phones show only Portrait(Force Update to Portrait).

I followed this link but I am getting this error and i dd't understand how can we create folders where can we place the data.I followed this link: but i didn't get

Android: allow portrait and landscape for tablets, but force portrait on phone?

解决方案

1.Go to the Android folder inside your RN Project,add values-sw600dp and values-xlarge to the following path:

android/app/src/main/res/values-sw600dp
android/app/src/main/res/values-xlarge

then add bools.xml to values,values-sw600dp,values-xlarge. the result:

2.Add code to MainActivity.java in the path android/app/src/main/java/com/[your project name]/MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getResources().getBoolean(R.bool.portrait_only)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}

这篇关于React-native Android Set only Portrait Mobile Phones 否则平板显示landScape和Portrait的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 18:01