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?
In Android Studio inside the res folder, one can find the drawable folder, layout folder, mipmap folder, values folder, etc. Among them, the drawable folder contains the different types of images used for the development of the application.
Supported file types are PNG (preferred), JPG (acceptable), and GIF (discouraged).
Simply go to project Explorer and change your View from Android to project from drop Down and you are good to go. There you can simply create folder like we do in Eclipse. And in android project view it is hidden but when you switch to project. You can create folder like drawable-hdpi,drawable-xhdpi .
Drag and drop your images directly onto the Resource Manager window in Android Studio. Alternatively, you can click the plus icon (+), choose Import Drawables, as shown in figure 3, and then select the files and folders that you want to import.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With