Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawable image scaling

If an asset is present in the drawable-xhdpi directory, do its equivalents need to be present in the drawable-hdpi/mdpi/ldpi directories as well in order to support those devices? Or, will Android downscale the xhdpi asset? If Android does downscale the asset, is there any benefit to using the lower dpi folders?

like image 695
Matthew Avatar asked Apr 14 '26 03:04

Matthew


2 Answers

One benefit to using the lower folder is that you get control over how the image is downscaled. High resolution images may not necessarily look the way you want when they are reduced, it depends on the filtering algorithm used and the content of the image. If the high precision image has too many small details it may look odd or grainy at small resolutions.

By placing your own image in the ldpi folder, you get artistic control over exactly how the image looks. You may wish to use a simpler image with less high frequency content in the smaller image, so that it is clearer and easier to see and understand.

like image 195
Tim Avatar answered Apr 17 '26 04:04

Tim


In addition to my comment on your question, I have a few reasons why you may want to include drawables in all folders:

  • If you have a drawable in xhdpi that's very high-res and has a lot of "activity" going on in it, it may look terrible and clustered when scaled down. Thus, you could create smaller, similar versions of that icon (named similarly across these density folders) that contain less "cluster" as you move down in size.

  • Different size layouts may want different size icons, and the scaling may not occur as you personally want it, so making your own scaled drawables would (mostly) prevent this.

  • Lint will yell at you if you don't put drawables in all the density folders.

If I think of any more reasons I'll add them.

like image 40
Mxyk Avatar answered Apr 17 '26 03:04

Mxyk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!