Android-Manifest Activity 标签-屏幕方向已弃用

问题描述 投票:0回答:2

Android Studio 考拉 | 2024.1.1 金丝雀 5

清单中的屏幕方向标签已弃用,因此我正在寻找替代解决方案。

Gradle 插件版本 - 8.3.1

android:screenOrientation="portrait"

抑制工具 -

tools:ignore="DiscouragedApi" 

enter image description here

谢谢!

android android-studio android-gradle-plugin
2个回答
0
投票

在 GetStartedActivity 中尝试

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);


0
投票

此活动预计 android:screenOrientation="unspecified" 或 "fullSensor",以便用户可以在任何方向使用该应用程序,并在 Chrome 操作系统设备上提供出色的体验

检查信息:元素不应锁定到任何方向,以便用户可以利用 Android 上的多窗口环境和更大的屏幕。要解决此问题,请考虑使用

screenOrientation="unspecified"or "fullSensor"
属性声明相应的活动元素。

enter image description here

考虑在活动中使用

android:screenOrientation="unspecified"
"fullSensor"
允许用户以任何方向使用应用程序,特别是对于 Chrome 操作系统设备

<activity>
元素不应固定在特定方向,以最大限度地提高多窗口环境和较大屏幕上的可用性。因此,解决此问题时请使用
screenOrientation="unspecified"
"fullSensor"
属性更新活动元素

警告对于不限制大屏幕设备上的方向非常重要。如果您的应用程序仅设计用于纵向模式 sso,您可以通过添加

tools:ignore="LockedOrientationActivity"
单独活动或顶级
<manifest>
标签以全局应用它来抑制警告。

<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:ignore="LockedOrientationActivity">
更多详情请参阅:

  • 来源锁定定向活动
  • Android 开发者指南:窗口管理
如果遇到任何意外行为,可以报告问题

Google问题跟踪器

© www.soinside.com 2019 - 2024. All rights reserved.