本文介绍了清单限制为仅平板电脑,但应用仍是提供给三星Galaxy S2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想在平板电脑上运行我的应用程序。因此,我宣布以下清单文件code:

I want to run my app only in tablets. So I have declared below code in manifest file:

<supports-screens 
    android:smallScreens="false"
    android:normalScreens="false"
    android:largeScreens="true"
    android:xlargeScreens="true"
    android:anyDensity="false"
    android:requiresSmallestWidthDp="600"/>

但是,当我连接我的三星Galaxy S2手机(华电国际480×800 ),它仍然显示在Eclipse的Andr​​oid设备选择器。

But when I connect my Samsung Galaxy S2 phone (hdpi 480x800), it still displays in Eclipse's Android device chooser.

我只想7支持和10平板电脑。我该怎么做?

I only want to support for 7" and 10" tablets. How can I do that?

推荐答案

您可能想看看的。

您写的清单限制不完全正确的用于此目的:

The manifest restrictions you wrote are not exactly correct for this purpose:

使用这样的:

<supports-screens android:smallScreens="false"
                  android:normalScreens="false"
                  android:largeScreens="false"
                  android:xlargeScreens="true"
                  android:requiresSmallestWidthDp="600" />

这说明了两种不同的方式应用的屏幕尺寸支持:

This describes your app’s screen-size support in two different ways:

据声明应用程序不支持屏幕大小水桶小,正常和大,这是历来没有片

It declares that the app does not support the screen size buckets "small", "normal", and "large", which are traditionally not tablets

据宣布,该应用程序需要以最小使用面积至少是600dp的屏幕尺寸宽

It declares that the app requires a screen size with a minimum usable area that is at least 600dp wide

第一种方法是对于那些运行Android 3.1或以上,因为这些设备基于广义屏幕大小水桶申报大小的设备。该requiresSmallestWidthDp属性是运行Android 3.2和较新的设备,这增加了能力的应用程序基于密度独立像素的最小数量指定他们的尺寸要求。在这个例子中,该应用声明为600dp的最小宽度的要求,这通常意味着7或者 - 更大的屏幕

The first technique is for devices that are running Android 3.1 or older, because those devices declare their size based on generalized screen size buckets. The requiresSmallestWidthDp attribute is for devices running Android 3.2 and newer, which added the capability for apps to specify their size requirements based on a minimum number of density-independent pixels. In this example, the app declares a minimum width requirement of 600dp, which generally implies a 7"-or-greater screen.

您选择的大小可能会有所不同,当然,根据你的设计在多大程度上适用于不同的屏幕尺寸;例如,如果你的设计作品以及只对9或更大,您可能需要720dp的最小宽度的屏幕。

Your size choice might be different, of course, based on how well your design works on different screen sizes; for example, if your design works well only on screens that are 9" or larger, you might require a minimum width of 720dp.

美中不足的是,你必须按顺序使用requiresSmallestWidthDp属性编译你对机器人3.2或更高版本的应用程序。旧版本不明白这个属性,并会引发一个编译时错误。做最安全的事情就是发展你的应用程序对您为的minSdkVersion设置API级别相匹配的平台。当你做最后的preparations建立你的候选发布版,构建目标更改为Android 3.2及添加requiresSmallestWidthDp属性。 Android的版本比3.2年长简单地忽略了XML属性,所以没有一个运行时失败的风险。

The catch is that you must compile your application against Android 3.2 or higher in order to use the requiresSmallestWidthDp attribute. Older versions don’t understand this attribute and will raise a compile-time error. The safest thing to do is develop your app against the platform that matches the API level you’ve set for minSdkVersion. When you’re making final preparations to build your release candidate, change the build target to Android 3.2 and add the requiresSmallestWidthDp attribute. Android versions older than 3.2 simply ignore that XML attribute, so there’s no risk of a runtime failure.

这篇关于清单限制为仅平板电脑,但应用仍是提供给三星Galaxy S2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 01:24