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

后端 未结 3 826
野的像风
野的像风 2020-12-30 16:35

I\'m trying to understand how the res/drawables images should work with different screen densities. Right now I\'ve got a 1.5 app, and for example, I have an image that is 1

3条回答
  •  臣服心动
    2020-12-30 17:19

    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

提交回复
热议问题