9
votes

I've a full set of images at the various different pixel densities, and I need to put bitmap resources into the drawables folder (at MDPI) to use as default resources (to prevent crashing on pixel density devices I've not catered to, e.g. xhdpi), but that means duplicating the resources in the drawable-mdpi into the drawable folder.

So as duplication is clearly bad, I'm wondering whether I should just delete the drawable-mdpi folder, and keep my MDPI resources in the (default) drawable folder

Or am I missing something?

2

2 Answers

16
votes

You don't need to duplicate your resources. A good practice is to do the following: - Put all non image-based drawables inside res/drawable/ (for instance all your XML drawables) - Put all image-based drawables (images and 9-patches) inside res/drawable-mdpi, res/drawable-hdpi, etc.

1
votes

All I would say, is that obviously Romain guy is correct about using drawables to keep xml files in and then moving image resources into the relevant mdpi, hdpi and ldpi folders, the only time I'd go against this is when you wish to target 1.5 devices.

The reason for this is that because 1.5 has no recognition for the -hdpi, -mdpi and -ldpi tags, it ignores them and picks resources (seemingly randomly) from each folder, so instead you have to add the following flag -hdpi-v4, -mdpi-v4, -ldpi-v4, this will then make those folders accessible by 1.6+ versions of Android forcing 1.5 to only see the drawable folder, at which point you need to have all your resources in drawable, which then removes the need to have the drawable-mdpi folder.

However, since 1.5 is getting on a bit and such few devices have it, it makes more sense to target 1.6+ and ignore this complication.