I was working on Android 1.5, but I have now moved to the latest version. So there is only one "drawable" folder in Android 1.5, but now there are three different folders for storing images in the Android project.
And I have found some articles for these three folders that says
But what is the exact purpose of these three folders and when should I use a particular folder to store images in?
The size are not exact but upto 130dpi it is considered small, from 130 to 180 it can be considered mdpi, from 180 to 200 it can be considered as hdpi and the higher is classified as xdpi.
these are image folders for different densities. hdpi images for the Android Broad Screen set or Android Phones with the Higher resolution. ldpi Lower images quality supported by the earlier sets of the android. mdpi for medium images support. xhdi devices with maximum resolution.
Option #1: Just ship the -xxhdpi drawables and let Android downsample them for you at runtime (downside: will only work on fairly recent devices, where -xxhdpi is known). Option #2: Use Android Asset Studio to downsample them for you. Option #3: Automate the process within a graphics editor, per ssantos' answer.
mdpi is the reference density -- that is, 1 px on an mdpi display is equal to 1 dip.
To declare different layouts and bitmaps you'd like to use for the different screens, you must place these alternative resources in separate directories/folders.
This means that if you generate a 200x200
image for xhdpi
devices, you should generate the same resource in 150x150
for hdpi
, 100x100
for mdpi
, and 75x75
for ldpi
devices.
Then, place the files in the appropriate drawable resource directory:
MyProject/ res/ drawable-xhdpi/ awesomeimage.png drawable-hdpi/ awesomeimage.png drawable-mdpi/ awesomeimage.png drawable-ldpi/ awesomeimage.png
Any time you reference @drawable/awesomeimage
, the system selects the appropriate bitmap based on the screen's density.
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