- 语法:
-
<compatible-screens> <screen android:screenSize=["small" | "normal" | "large" | "xlarge"] android:screenDensity=["ldpi" | "mdpi" | "hdpi" | "xhdpi" | "280" | "360" | "420" | "480" | "560" ] /> ... </compatible-screens>
- 包含于:
<manifest>
- 说明:
- 指定应用与之兼容的各个屏幕配置。清单中只能包含
<compatible-screens>
元素的一个实例,但可以包含多个<screen>
元素。每个<screen>
元素都指定了应用与之兼容的特定屏幕尺寸-密度组合。Android 系统不会读取
<compatible-screens>
清单元素(无论是在安装时还是在运行时)。此元素仅用于提供信息,可供外部服务(如 Google Play)用于更好地了解应用与特定屏幕配置的兼容性,并为用户启用过滤功能。未在此元素中声明的任何屏幕配置都是应用与之不兼容的屏幕。因此,外部服务(如 Google Play)不会向使用此类屏幕的设备提供应用。注意:正常情况下,不能使用此清单元素。使用此元素可能会显著减少应用的潜在用户群,因为如果您未列出用户所用设备的屏幕配置,则它不允许用户安装您的应用。只有在万不得已时,也就是应用绝对无法与特定屏幕配置一起使用时,才能使用此元素。您不应使用此元素,而应按照支持多种屏幕指南,为针对不同屏幕尺寸和密度使用备用布局的多种屏幕提供可扩展支持。
如果您只想为应用设置最小屏幕尺寸,则应使用
<supports-screens>
元素。例如,如果您希望应用仅适用于大屏幕和特大屏幕设备,则可以通过<supports-screens>
元素声明您的应用不支持小屏幕和标准屏幕尺寸。外部服务(如 Google Play)会相应地过滤您的应用。您还可以使用<supports-screens>
元素声明系统是否应根据不同的屏幕尺寸调整应用的大小。如需详细了解 Google Play 如何使用此清单元素和其他清单元素过滤应用,另请参阅 Google Play 上的过滤器文档。
- 子元素:
- 示例
-
如果您的应用仅与小屏幕和标准屏幕兼容(无论屏幕密度如何),则必须指定十二种不同的
<screen>
元素,因为每种屏幕尺寸都有六个不同的密度配置。您必须声明这些元素之一;您未指定的任何尺寸和密度组合都会被视为您的应用与之不兼容的屏幕配置。如果您的应用仅与小屏幕和标准屏幕兼容,则清单条目如下所示:<manifest ... > ... <compatible-screens> <!-- all small size screens --> <screen android:screenSize="small" android:screenDensity="ldpi" /> <screen android:screenSize="small" android:screenDensity="mdpi" /> <screen android:screenSize="small" android:screenDensity="hdpi" /> <screen android:screenSize="small" android:screenDensity="xhdpi" /> <screen android:screenSize="small" android:screenDensity="xxhdpi" /> <screen android:screenSize="small" android:screenDensity="xxxhdpi" /> <!-- all normal size screens --> <screen android:screenSize="normal" android:screenDensity="ldpi" /> <screen android:screenSize="normal" android:screenDensity="mdpi" /> <screen android:screenSize="normal" android:screenDensity="hdpi" /> <screen android:screenSize="normal" android:screenDensity="xhdpi" /> <screen android:screenSize="normal" android:screenDensity="xxhdpi" /> <screen android:screenSize="normal" android:screenDensity="xxxhdpi" /> </compatible-screens> <application ... > ... <application> </manifest>
- 引入于:
- API 级别 9
- 另请参阅:
- 支持多种屏幕
- Google Play 上的过滤器
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022-03-01 UTC.
[]
[]