Search code examples
androidbitmapscreen-size

Android Bitmapfactory decoderesource which drawable will be used considering screen density


When you call:

    Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.disco);

Which version of "disco" will be used if I have a disco.png in each drawable-hdpi, drawable-mdpi and drawable-ldpi? Is it depending on the device using the code? If a hdpi - device is using the code will it use the hdpi image? I'm having trouble finding good docs on this, thanks in advance.


Solution

  • Yes, if you provide an hdpi drawable and run this code on an hdpi device, you will get that hdpi drawable. Read this document on how Android decides which resource to use.