android anydensity in manifest

2019-02-15 14:11发布

I have encountered an amazing problem, in my application.

When i put anyDensity tag false in manifest my application runs fine, but whenever i make it true my application acts blurry, i am creating some bitmaps on my application. any there is a problem if i do anyDensity tag false in manifest then many devices would not able to see my app on playstore, Any help will be appreciated.

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

2条回答
你好瞎i
2楼-- · 2019-02-15 14:18

not too much info in your original post, however. The documentation states:

Indicates whether the application includes resources to accommodate any screen density. For applications that support Android 1.6 (API level 4) and higher, this is "true" by default and you should not set it "false" unless you're absolutely certain that it's necessary for your application to work. The only time it might be necessary to disable this is if your app directly manipulates bitmaps

So my first question is do you include all resources to accomodate any screen density (i. e. mdpi, hdpi, xhdpi, xxhdpi)? If yes, You should be fine. Following the last sentences of the quote above I arrived at this link.

It says:

An application can disable pre-scaling by setting android:anyDensity to "false" in the manifest or programmatically for a Bitmap by setting inScaled to "false".

Have you tried doing it programmatically for your bitmaps, instead of disabling this flag globally for the whole app?

And finally there is this section. Maybe it will be helpful to you in properly handling your custom bitmaps? Specifically, this paragraph sound like your problem:

If your application creates an in-memory bitmap (a Bitmap object), the system assumes that the bitmap is designed for the baseline medium-density screen, by default, and auto-scales the bitmap at draw time. The system applies "auto-scaling" to a Bitmap when the bitmap has unspecified density properties. If you don't properly account for the current device's screen density and specify the bitmap's density properties, the auto-scaling can result in scaling artifacts the same as when you don't provide alternative resources.

查看更多
男人必须洒脱
3楼-- · 2019-02-15 14:39

You can use the aapt tool, included in the Android SDK, to determine how Google Play will filter your application, based on its declared features and permissions. To do so, run aapt with the dump badging command. It will parse your application's manifest and apply the same rules as used by Google Play to determine the features that your application requires. For detailed information on using this tool, please visit http://developer.android.com/guide/topics/manifest/uses-feature-element.html#testing

查看更多
登录 后发表回答