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?
-
2why would you want to reinvent the wheel? – panini Jul 10 '14 at 22:25
-
@panini I think this is more of a theoretical question. Would be interesting to know what happens with the different drawables at runtime. – fweigl Jul 10 '14 at 22:26
-
Im asking this bc i feel like its a pain to just add each image you want to all four folders - why not just 1 and specify dp? – committedandroider Jul 10 '14 at 22:39
2 Answers
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.

- 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
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.

- 21,278
- 20
- 114
- 205
-
Thanks for that. I didnt think of the resizing operations. My approach would involve countless resizing operations(cpu time and battery) – committedandroider Jul 10 '14 at 22:41