androidimageandroid-resourcesdpiscreen-density

What image (with smaller or higher DPI) is used to prepare the image when appropriate is missing?


I have phone with xhdpi screen. I use image abc.jpg but there is no such image for xhdpi. But there is an image with higher DPI (drawable-xxhdpi/abc.jpg) and with lower (drawable-hdpi/abc.jpg). Which one will be used to prepare (scale) the image for my density screen?


Solution

  • Excerpts from Android developers page:

    Note: Using a density qualifier doesn't imply that the resources are only for screens of that density. If you don't provide alternative resources with qualifiers that better match the current device configuration, the system may use whichever resources are the best match.

    Best Match:

    If the qualifier in question is screen pixel density, Android selects the option that most closely matches the device screen density. In general, Android prefers scaling down a larger original image to scaling up a smaller original image.

    Source page : https://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch

    Based on this I'd assume that the higher dpi image will be used, however a visual check would probably confirm this i.e. if the image isn't blurry it is probably safe to assume it hasn't been upscaled.