- 语法:
-
<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 上的过滤器
<兼容屏幕>
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# <compatible-screens\u003e\n\nsyntax:\n:\n\n ```xml\n \u003ccompatible-screens\u003e\n \u003cscreen android:screenSize=[\"small\" | \"normal\" | \"large\" | \"xlarge\"]\n android:screenDensity=[\"ldpi\" | \"mdpi\" | \"hdpi\" | \"xhdpi\"\n | \"280\" | \"360\" | \"420\" | \"480\" | \"560\" ] /\u003e\n ...\n \u003c/compatible-screens\u003e\n ```\n\ncontained in:\n: [\u003cmanifest\u003e](/guide/topics/manifest/manifest-element)\n\ndescription:\n: Specifies each screen configuration with which the application is compatible. Only one instance\n of the `\u003ccompatible-screens\u003e` element is allowed in the manifest, but it can\n contain multiple `\u003cscreen\u003e` elements. Each `\u003cscreen\u003e` element\n specifies a specific screen size-density combination with which the application is compatible.\n\n The Android system *doesn't* read the `\u003ccompatible-screens\u003e` manifest\n element at any point. This element is informational only and is used\n by external services, such as Google Play, to better understand the application's compatibility\n with specific screen configurations and to enable filtering for users.\n\n\n Any screen configuration that\n *isn't* declared in this element is a screen with which the application *isn't*\n compatible. External services, such as Google Play, don't provide the application to\n devices with such screens.\n\n\n **Caution:** Normally, *you don't use this manifest\n element* . Using this element can dramatically reduce the potential user base for your\n application by preventing users from installing your application if they have a device with a screen\n configuration that you don't list. Use it only as a last resort, when the\n application absolutely doesn't work with specific screen configurations. Instead of using this\n element, follow the guide to [supporting multiple screens](/guide/practices/screens_support) to\n provide scalable support for multiple screens using alternative layouts and bitmaps\n for different screen sizes and densities.\n\n\n If you want to set a minimum screen size for your your application, use the [`\u003csupports-screens\u003e`](/guide/topics/manifest/supports-screens-element) element. For example, if you want your application to be available\n only for large and extra-large screen devices, the `\u003csupports-screens\u003e` element lets\n you declare that your application doesn't support small and normal screen sizes.\n Then, external services like Google Play filter your application accordingly. You can also use the\n `\u003csupports-screens\u003e` element to declare whether the system can resize your\n application for different screen sizes.\n\n\n For more information about how Google Play filters applications using this and\n other manifest elements, see [Filters on Google Play](/google/play/filters).\n\n\nchild elements:\n:\n\n `\u003cscreen\u003e`\n\n : Specifies a single screen configuration with which the application is compatible.\n\n At least one instance of this element must be placed inside the `\u003ccompatible-screens\u003e`\n element. This element must include both the `android:screenSize` and\n `android:screenDensity` attributes. If you don't declare both\n attributes, then the element is ignored.\n\n Attributes:\n\n `android:screenSize`\n : **Required.** Specifies the screen size for this screen configuration.\n\n Accepted values:\n\n - `small`\n - `normal`\n - `large`\n - `xlarge`\n\n\n For information about the different screen sizes, see [Screen compatibility overview](/guide/practices/screens_support#sizes).\n\n `android:screenDensity`\n : **Required.** Specifies the screen density for this screen configuration.\n\n Accepted values:\n\n - `\"ldpi\"` (approximately 120 dpi)\n - `\"mdpi\"` (approximately 160 dpi)\n - `\"hdpi\"` (approximately 240 dpi)\n - `\"xhdpi\"` (approximately 320 dpi)\n - `\"280\"`\n - `\"360\"`\n - `\"420\"`\n - `\"480\"`\n - `\"560\"`\n\n\n For information about the different screen densities, see [Screen compatibility overview](/guide/practices/screens_support#density).\n\n\nexample\n\n: If your application is compatible with only small and normal screens, regardless\n of screen density, then you must specify 12 `\u003cscreen\u003e` elements,\n because each screen size has six different density configurations.\n\n You must declare each one of\n these. Any combination of size and density that you *don't* specify is considered a screen\n configuration with which your application *isn't* compatible. Here's what the manifest\n entry looks like if your application is compatible with only small and normal screens: \n\n ```xml\n \u003cmanifest ... \u003e\n ...\n \u003ccompatible-screens\u003e\n \u003c!-- all small size screens --\u003e\n \u003cscreen android:screenSize=\"small\" android:screenDensity=\"ldpi\" /\u003e\n \u003cscreen android:screenSize=\"small\" android:screenDensity=\"mdpi\" /\u003e\n \u003cscreen android:screenSize=\"small\" android:screenDensity=\"hdpi\" /\u003e\n \u003cscreen android:screenSize=\"small\" android:screenDensity=\"xhdpi\" /\u003e\n \u003cscreen android:screenSize=\"small\" android:screenDensity=\"xxhdpi\" /\u003e\n \u003cscreen android:screenSize=\"small\" android:screenDensity=\"xxxhdpi\" /\u003e\n \u003c!-- all normal size screens --\u003e\n \u003cscreen android:screenSize=\"normal\" android:screenDensity=\"ldpi\" /\u003e\n \u003cscreen android:screenSize=\"normal\" android:screenDensity=\"mdpi\" /\u003e\n \u003cscreen android:screenSize=\"normal\" android:screenDensity=\"hdpi\" /\u003e\n \u003cscreen android:screenSize=\"normal\" android:screenDensity=\"xhdpi\" /\u003e\n \u003cscreen android:screenSize=\"normal\" android:screenDensity=\"xxhdpi\" /\u003e\n \u003cscreen android:screenSize=\"normal\" android:screenDensity=\"xxxhdpi\" /\u003e\n \u003c/compatible-screens\u003e\n \u003capplication ... \u003e\n ...\n \u003capplication\u003e\n \u003c/manifest\u003e\n ```\n\nintroduced in:\n: API level 9\n\nsee also:\n: [Screen compatibility overview](/guide/practices/screens_support)\n: [Filters on Google Play](/google/play/filters)"]]