Not able to understand how to use different density images for 1.6+?

不打扰是莪最后的温柔 提交于 2019-11-30 07:55:33

ldpi, mdpi, and hdpi correspond to density "classes", not the actual density of the device.

For instance the G1 is a mdpi class device (160dpi) but its screen density is actually around 180dpi. The droid is a hdpi class device (240dpi) but its screen is 265dpi.

Bitmap scaling is based on the density class only. The actual screen density is ignored.

So a G1 will show mdpi bitmaps slightly smaller than a mdpi device with a true 160dpi screen, but this is a very small difference so it's not a big deal.

(Note that other dimension types, such as "in" and "mm", do take into account the screen density.)

So for densities you have 3 choices: ldpi (120), mdpi (160) and hdpi (240). Therefore, your 100x100 bitmap should be 75x75, 100x100, and 150x150 respectively.

For more info see: http://developer.android.com/guide/practices/screens_support.html#qualifiers

You can never be sure to cover all possible screen sizes. But if your layout arranges items automatically, you can set the absolute image size with px instead of dip.

Maybe you also want to use (small/normal/large) instead of (ldpi/mdpi/hdpi), because the former refer to screen size instead of density. Resource directory qualifiers

The behavior also depends on what your manifest declares, specifically the tag in the manifest (you can configure it using "manifest extras" in the first tab in ADT's Manifest Editor).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!