【问题标题】:Android studio 3.6 give an redline for android:screenOrientation="portrait", need to change android:screenOrientation="fullSensor"?Android studio 3.6 给 android:screenOrientation="portrait" 加红线,需要更改 android:screenOrientation="fullSensor" 吗?
【发布时间】:2020-02-28 12:40:57
【问题描述】:

当我更新 android studio 3.6 时,它会在 android:screenOrientation="portrait" 下方给我一条红线。

它的发言权改为android:screenOrientation="fullSensor"

谁能知道背后的原因是什么?

【问题讨论】:

    标签: android android-manifest android-studio-3.6


    【解决方案1】:

    在 Android Studio 3.6.0 中,我猜他们希望用户处理方向并鼓励开发人员使用 ViewModel 的东西。让我详细解释一下screenOrientation

    android:screenOrientation="portrait"

    会给你错误,你必须指定

    android:screenOrientation="fullSensor" or android:screenOrientation="unspecified"

    fullSensor 表示您是否开启了“旋转关闭”功能,它会根据您移动手机而改变方向

    未指定表示如果您开启了“旋转”关闭,那么它将仅保持在该方向,如果没有,它将根据您移动手机而改变方向。

    【讨论】:

    • 所以根据您的回答,我们只有两个选择,那么如果我只想将方向锁定为纵向呢?
    • 如果我只想要方向“纵向”模式怎么办。
    • 在应用程序标签中应用工具:ignore="LockedOrientationActivity",它会忽略您对 screenOrientation 的所有警告。
    【解决方案2】:

    以 Deep Sheth 的回答为基础,这是警告而非错误。

    建议您在 Activity 中设置 fullSensorunspecified,以便用户可以在任何方向使用应用程序并在 Chrome OS 设备中提供出色的体验

    您可以通过在清单中的活动声明中添加以下内容来消除该警告:tools:ignore="LockedOrientationActivity"

    【讨论】:

      【解决方案3】:

      我用过下面的..

      1. 在下面添加清单文件..

        xmlns:tools="http://schemas.android.com/tools"
        tools:ignore="LockedOrientationActivity"> 
        
      2. 清单文件看起来像..

        <?xml version="1.0" encoding="utf-8"?>
        <manifest xmlns:android="http://schemas.android.com/apk/res/android"
           package="com.yourpackage"
           xmlns:tools="http://schemas.android.com/tools"
           tools:ignore="LockedOrientationActivity">
        .....
        <activity
          android:name=".MainActivity"
          android:theme="@style/AppTheme.NoActionBar"
          android:screenOrientation="portrait"
          android:configChanges="orientation|keyboardHidden"/>
        
         </manifest>
        

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-02-19
        • 2012-12-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多