Android官方文档—APP清单(compatible-screens)

语法:



    <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>

指定与应用程序兼容的单个屏幕配置。

必须至少将此元素的一个实例放在<compatible-screens>元素内。此元素必须包含android:screenSize和android:screenDensity属性(如果不声明这两个属性,则忽略该元素)。

属性:

android:screenSize

必要。指定此屏幕配置的屏幕大小。

可接受的值:

  • small
  • normal
  • large
  • xlarge

有关不同屏幕尺寸的信息,请参阅支持多个屏幕。

android:screenDensity

必要。指定此屏幕配置的屏幕密度。

可接受的值:

  • "ldpi" (approximately 120 dpi)
  • "mdpi" (approximately 160 dpi)
  • "hdpi" (approximately 240 dpi)
  • "xhdpi" (approximately 320 dpi)
  • "280"
  • "360"
  • "420"
  • "480"
  • "560"

有关不同屏幕密度的信息,请参阅支持多个屏幕。

例子:

如果您的应用程序仅与小屏幕和普通屏幕兼容,无论屏幕密度如何,则必须指定12个不同的<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 Level 9

参阅:

Supporting Multiple Screens

Filters on Google Play

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值