Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: drawable resolutions

I've been through this post (and others) as well as through the documentation about supporting different screen resolutions in Android, but I couldn't find a clear answer to a (simple) question:

Is it ok to just use "res/drawable" for images in an android app?

Background: The only images that are needed in this specific app are the app icon itself and an icon for a notification, there won't be any images in any layout.
So in my understanding, if no "hdpi"-, "mdpi"- and "ldpi"-folders are found, Android will use "res/drawable" as the fallback.
As the only pitfall with different screen-resolution seems to be that Android will scale images for a specific resolution if no special one is found, this should only be a problem when UPscaling, because the image will get blurry. But if I provide all "hdpi"-images in "res/drawable" (instead of 3 different ones), won't Android just DOWNscale those images if the size is too big?
If that's true, I could save some APK-space by just a third of the images.

Follow-Up question: I read that for API-level 3 a dir by the name "drawable-v3" is required. Is that true or is "drawable" the fallback for this API-level also?

Any hint is appreciated.

like image 690
Select0r Avatar asked Feb 15 '11 22:02

Select0r


3 Answers

The images in the drawables folder are assumed to be at mdpi resolution, so they will get scaled up/down if you don't provide the others.

Scaled up images will be low-resolution and look fuzzy. Scaled down images will have pixels missing and look jaggy.

So your app will "work" with only one set of default images, but will look awful on many devices. I strongly advise that you create the images in different sizes, so it looks great on all devices - it's a bit boring, but not hard to do.

It won't be long before we have xhdpi devices, so while you're at it you may want to create those too.

I assume you've read this

like image 111
Ollie C Avatar answered Oct 10 '22 11:10

Ollie C


Not a complete answer, but: highly downscaled images can and usually do look just as bad as upscaled images (but in a different way), because graphics libraries almost exclusively use interpolation methods for resizing, and interpolation methods are limited in terms of how much they can shrink an image before serious information loss (to about 50% for linear methods and down to about 25% for bicubic methods). This is why most platforms have evolved conventions (like hdpi, mdpi etc.) that let you embed images that are best for each screen size.

like image 26
MusiGenesis Avatar answered Oct 10 '22 11:10

MusiGenesis


I use drawable/ all the time, and then I go to BestBuy and all the local wireless stores and test my apps on small/large/huge(tablet) devices and they look just fine.

like image 37
Rich Avatar answered Oct 10 '22 13:10

Rich