Reputation: 3627
For example, I provide some image in ldpi, mdpi and xhdpi folder.
When I run app on device with hdpi density, which resource will it pick - ldpi or mdpi?
Upvotes: 2
Views: 1479
Reputation: 22945
Consider MDPI is 1. Then, LDPI is 0.75 and HDPI is 1.5. What that means is that if you have a drawable that is, say, 50x50 on a MDPI screen it will have to be ~37x37 on a LDPI screen and 75x75 on a HDPI screen.
If you do not supply special drawables for each density, Android will scale the closest one available automatically.
You should not consider the DPI of a device to have anything to do with screen size and/or number of pixels and/or resolution and/or aspect ratio. A device could be very small and have an HDPI screen or very large and have an LDPI screen
ldpi Resources for low-density (ldpi) screens (~120dpi). mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.) hdpi Resources for high-density (hdpi) screens (~240dpi). xhdpi Resources for extra-high-density (xhdpi) screens (~320dpi). xxhdpi Resources for extra-extra-high-density (xxhdpi) screens (~480dpi). xxxhdpi Resources for extra-extra-extra-high-density (xxxhdpi) uses (~640dpi). Use this for the launcher icon only, see note above.
please check http://developer.android.com/guide/practices/screens_support.html and SO answer https://stackoverflow.com/a/6373533/2826147
Upvotes: 1
Reputation: 902
In this case android chooses **mdpi*. You can read more about How Android Finds the Best-matching Resource
Upvotes: 2
Reputation: 946
Taken from http://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch
If no matching resource is available, the system uses the default resource and scales it up or down as needed to match the current screen size and density The "default" resources are those that are not tagged with a configuration qualifier. For example, the resources in drawable/ are the default drawable resources. The system assumes that default resources are designed for the baseline screen size and density, which is a normal screen size and a medium-density. As such, the system scales default density resources up for high-density screens and down for low-density screens, as appropriate. However, when the system is looking for a density-specific resource and does not find it in the density-specific directory, it won't always use the default resources. The system may instead use one of the other density-specific resources in order to provide better results when scaling. For example, when looking for a low-density resource and it is not available, the system prefers to scale-down the high-density version of the resource, because the system can easily scale a high-density resource down to low-density by a factor of 0.5, with fewer artifacts, compared to scaling a medium-density resource by a factor of 0.75.
Upvotes: 4