1

I don't get why it's recommended to have a drawable (image) for all densities (ldpi, ..., xxhdpi).

Would it not be better to add one file with the highest needed density (xxxhdpi) and than programmatically scale that image down (e.g. for tab icons I could just set a explicit dp size)?

Therefore I would only have to manage one file and the APK file size would be smaller. I think the performance disadvantage should not be significant.

Update 1:

To be more specific: I never noticed any quality loss when using a high density image (PNG file) which was scaled down to a explicit dp value on my mdpi device.

So I was considering if the disadvantages of managing multiple image files as a coder without a designer (and the higher APK file size) might outweigh the advantages. Especially if I'm going to target newer devices (API >= 17).

Update 2:

In my case I'm more a coder than a designer. In the microphone example image of @mes I could just use a high density version of the left microphone and scale it down with no significant disadvantages?

Steffen
  • 2,197
  • 2
  • 24
  • 38
  • If you're worried about the final size of your apk, did you know you can create [multiple apks for multiple screen sizes](http://developer.android.com/training/multiple-apks/screensize.html)? – Joao Sousa Feb 25 '15 at 13:26
  • Thanks @JoaoSousa I will keep that in mind. But my main concern is managing the multiple image resources as I'm a indie developer with minor design (photoshop) skills. ;-) – Steffen Feb 25 '15 at 13:34
  • I also say the same :) – mes Feb 25 '15 at 13:34

3 Answers3

3

There's no significant advantage, when designer or you simply reduce image size and put inside the ldpi, actual meaning is to paint another image for small size, because there are many cases, when simply reducing an image size produces inacurate and low quality image, and a good designer will draw another image, with few details in it, this is an example, only in this case worth to put different images in different folders Icons

Therefore I would only have to manage one file and the APK file size would be smaller. I think the performance disadvantage should not be significant.

Yes, you are right, there no significant performance improvements, and also apk size is increases, that's why not worth to downscale the same image.

mes
  • 3,581
  • 29
  • 28
  • Saying there's no advantage is a plain lie. – Joao Sousa Feb 25 '15 at 13:27
  • I said "there no significant performance improvements", I want to say, that main reason in not a performance, because there can be multiple optimization solutions for that, but produce another image, with few details in it, it is only designer can, and main purpose is that, I'm also designer, not only a coder, and know, that there are not only performance improvements in the programming, the pixel art is also important :) – mes Feb 25 '15 at 13:31
  • 1
    Thanks @mes I think your answer fits the most. I will leave the question open for a few more hours to see if there are some other opinions - if not I will accept your answer! :-) – Steffen Feb 25 '15 at 13:51
0

There are two reasons for this:

  • Typically, devices with lower density screens also tend to have less powerful hardware for image & graphics processing, along with lower memory.
  • Its not just the density, it is also the file size and image dimensions that are scaled accordingly.

The Android way of having different drawables for different screen form factors is thus appropriate from a technical standpoint.

Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
  • not to mention that scaling down can cause artifacts in the final bitmap. – Joao Sousa Feb 25 '15 at 13:24
  • Scaling down inside photoshop or another paint editor also can cause artifacts, who says that android scales bad and we need to scale the same image in the image editor. The main reason is related to design, to make another low detail, but hight quality image. – mes Feb 25 '15 at 13:43
0

First advantage is what mes mentioned: different images for different sizes.

Second advantage is memory/code efficiency: a 1000x1000 pixels image on android will take 1000x1000x4 ~= 3.8 mb of memory which is really wasted on smaller screens which can have 16mb available memory per app. You could try loading the bitmaps efficiently but that's a lot of code to put/maintain for each image and also will have performance issues on some cases.

Evripidis Drakos
  • 872
  • 1
  • 7
  • 15