- cú pháp:
-
<compatible-screens> <screen android:screenSize=["small" | "normal" | "large" | "xlarge"] android:screenDensity=["ldpi" | "mdpi" | "hdpi" | "xhdpi" | "280" | "360" | "420" | "480" | "560" ] /> ... </compatible-screens>
- có trong:
<manifest>
- nội dung mô tả:
- Chỉ định từng cấu hình màn hình tương thích với ứng dụng. Trong tệp kê khai chỉ được phép có một thực thể của phần tử
<compatible-screens>
nhưng thực thể này có thể chứa nhiều phần tử<screen>
. Mỗi phần tử<screen>
chỉ định một tổ hợp mật độ – kích thước màn hình cụ thể mà ứng dụng tương thích.Hệ thống Android không đọc phần tử tệp kê khai
<compatible-screens>
vào bất cứ lúc nào. Phần tử này chỉ nhằm mục đích cung cấp thông tin và có thể được các dịch vụ bên ngoài (ví dụ như Google Play) sử dụng để hiểu rõ hơn về khả năng tương thích của ứng dụng với các cấu hình màn hình cụ thể, cũng như để cho phép người dùng lọc dữ liệu.Mọi cấu hình màn hình không được khai báo trong phần tử này đều là màn hình mà ứng dụng không tương thích. Các dịch vụ bên ngoài (chẳng hạn như Google Play) không cung cấp ứng dụng cho các thiết bị có màn hình như vậy.
Thận trọng: Thông thường, bạn không nên sử dụng phần tử tệp kê khai này. Việc sử dụng phần tử này có thể làm suy giảm đáng kể cơ sở người dùng tiềm năng cho ứng dụng của bạn bằng cách ngăn người dùng cài đặt ứng dụng đó nếu họ có thiết bị dùng cấu hình màn hình mà bạn không liệt kê. Chỉ nên dùng phần tử này làm phương án cuối cùng, khi ứng dụng hoàn toàn không hoạt động được với các cấu hình màn hình cụ thể. Thay vì sử dụng phần tử này, hãy làm theo hướng dẫn hỗ trợ nhiều màn hình để cung cấp tính năng hỗ trợ có thể mở rộng cho nhiều màn hình bằng cách dùng các bố cục và bitmap thay thế cho nhiều kích thước và mật độ màn hình.
Nếu bạn muốn đặt kích thước màn hình tối thiểu cho ứng dụng, hãy dùng phần tử
<supports-screens>
. Ví dụ: nếu bạn chỉ muốn ứng dụng dùng được cho các thiết bị có màn hình lớn và cực lớn, thì phần tử<supports-screens>
sẽ cho phép bạn khai báo rằng ứng dụng không hỗ trợ các kích thước màn hình nhỏ và bình thường. Sau đó, các dịch vụ bên ngoài như Google Play sẽ lọc ứng dụng của bạn cho phù hợp. Bạn cũng có thể dùng phần tử<supports-screens>
để khai báo xem hệ thống có thể đổi kích thước ứng dụng đó theo nhiều kích thước màn hình hay không.Để biết thêm thông tin về cách Google Play lọc các ứng dụng bằng phần tử này và các phần tử tệp kê khai khác, hãy xem bài viết Bộ lọc trên Google Play.
- phần tử con:
- ví dụ
-
Nếu ứng dụng của bạn chỉ tương thích với các màn hình có kích thước nhỏ và bình thường, bất kể mật độ màn hình, thì bạn phải chỉ định 12 phần tử
<screen>
, bởi vì mỗi kích thước màn hình có 6 cấu hình mật độ.Bạn phải khai báo từng phần tử trong số này. Mọi tổ hợp kích thước và mật độ mà bạn không chỉ định sẽ được coi là cấu hình màn hình mà ứng dụng không tương thích. Sau đây là ví dụ minh hoạ mục nhập tệp kê khai nếu ứng dụng chỉ tương thích với các màn hình có kích thước nhỏ và bình thường:
<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>
- ra mắt từ:
- API cấp 9
- xem thêm:
- Tổng quan về khả năng tương thích với màn hình
- Bộ lọc trên Google Play
<màn hình tương thích>
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],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)"]]