0

I read on Where to store images in Android drawables folder? that each drawable folder is for a different density - so images look different on each screen screen density. (larger on hdpi, smaller on xdpi). Would be as valid development approach to put all my images in the most generic folder(just drawable - for all densities) and just specify the image width and height using dp(density independent pixel, will scale). What would be the difference between the two approaches?

Community
  • 1
  • 1
committedandroider
  • 8,711
  • 14
  • 71
  • 126

2 Answers2

4

You could try all sorts of things - putting your own images in the Assets folder and scaling by hand, or doing what you suggested.

However, you asked about the most valid development approach, so I'm not going to talk about the feasibility of putting all your images in the Drawable folder, but the maintainability and effectiveness of doing so.

Android takes care of differences in densities via the density bucket folders, which work quite well. There's no need to spend development time working out a custom solution that might be difficult for other developers to follow.

JustSoAmazing
  • 747
  • 4
  • 8
  • I think the best way is the one specified above(not my approach). By just specifying an image to each drawable folder, you dont make the android os do the recalculation each time, it just picks the image and doesnt do any resizing – committedandroider Jul 10 '14 at 22:43
1

My guess is that the android system selects the drawables from the respective folders (hdpi, mdpi etc) instead of resizing them. Resizing bitmaps seems like a very expensive operation that uses cpu time and thus battery etc. and simply selecting a file from a folder according to the device's screen is inexpensive.

fweigl
  • 21,278
  • 20
  • 114
  • 205