Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawable-hdpi, Drawable-mdpi, Drawable-ldpi Android

Tags:

android

image

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

  1. hdpi means High-dpi
  2. mdpi means medium-dpi
  3. ldpi means low-dpi

But what is the exact purpose of these three folders and when should I use a particular folder to store images in?

like image 206
Paresh Mayani Avatar asked Jul 16 '10 08:07

Paresh Mayani


People also ask

What is the difference between Mdpi and Hdpi?

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.

What is drawable Hdpi in Android?

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.

Is there a way to create Xxhdpi Xhdpi Hdpi Mdpi and LDPI Drawables from a large scale image?

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.

What is Mdpi image?

mdpi is the reference density -- that is, 1 px on an mdpi display is equal to 1 dip.


1 Answers

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.

like image 68
Neha Mangla Avatar answered Oct 19 '22 16:10

Neha Mangla