Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: only use xxhdpi images

Is there any drawback in only using xxhdpi images and letting android scale the images? (Yes it might be more cpu intensive, but is it notable?) I tested it on a samsung s2 and the difference were small.

Is there a restriction to only use this if set minSdk to XX, becaus there were no xxhdpi?

like image 877
suizo Avatar asked Jan 31 '14 15:01

suizo


3 Answers

Here are a couple drawbacks I can think of:

  • More CPU intensive to resize the images, the app will use more battery and might feel more sluggish, especially on older devices.
  • The images that you are going to load will be bigger and will use more memory. On mdpi/hdpi devices, the VM in which your app run will only have a smaller amount of heap memory available, and you might run into Out Of Memory Exceptions much more frequently if you only load high quality images.
  • The quality of the image might not be as good on mdpi/hdpi devices, because of the resizing. This really depends on what image you are loading, but images with sharp lines might appear a little blurred. But I also want to point out that this only applies if you are really making pngs for each size from a vector graphic. If you are just resizing your xxhdpi png into smaller one, you're probably doing the exact same thing that android is doing on the fly, so there will be no difference at all.
like image 112
nbarraille Avatar answered Oct 13 '22 08:10

nbarraille


Yes, drawable xxhdpi was introduced in API 19. If you want to run your app in a lower API level, you wont get any image because the system can't access the xxhdpi drawables.

This is also true if you only use only xhdpi with Android 2.3.

like image 2
Stephane Mathis Avatar answered Oct 13 '22 08:10

Stephane Mathis


I'm not so sure there is going to be an image quality difference: even if you do provide the different versions of the graphic, they're likely just downscales of the original anyway. I'm willing to bet the difference between doing it at run-time and design-time is not going to be significant enough for a user to notice on a mobile phone screen.

I'm also not sure about a performance difference - however, even you admit that there is likely to be a non-zero negative impact. Given that fact, I think it's worth asking "Why not provide pre-scaled graphics?" There are tools (like the Android Asset Studio Icon Generator) that bring the level of effort required to make that happen almost to 0.

In mobile, any deal where you trade nearly 0 work for any potential performance enhancement is a deal you should take.

like image 1
sigmabeta Avatar answered Oct 13 '22 10:10

sigmabeta