Drawable-Hdpi, Drawable-Mdpi, Drawable-Ldpi Android

What's differences between 'drawable' folder and 'drawable-hdpi-ldpi-mdpi-xhdpi' folders?

res/drawable/ is equivalent to res/drawable-mdpi/. The suffix-less name is there for backwards compatibility, before the densities were added in Android 1.5 or thereabouts.

is enough to create suitable image size rate for all devices?

If you do not mind Android scaling your images up and down for other densities, yes. Usually, the quality will degrade the further the density is from the starting point (in this case, -mdpi.

Should I create image size rate for each folder(hdpi, mdpi, ldpi, xhdpi) ?

That depends on the image and the results of the automatic scaling. Many developers will ship a couple of densities, but not all of them, and tending to aim towards higher densities (e.g., -xhdpi). But, you are welcome to do what you want, so long as you feel that your users will be comfortable with the image quality that you deliver to them.

drawable vs. drawable-ldpi/drawable-mdpi

I believe this was added in Android 1.6. It's all explained here: http://developer.android.com/guide/practices/screens_support.html

confusion about drawable-hdpi,drawable-mdpi,drawable-ldpi and drawable

drawable folder is used for default images if the images are not found in the respective folders then it will look into the drawable folder.

I found this phrase in the doc:

For example, imagine you have an application icon, icon.png, and need unique version of it for different locales. However, two locales,
English-Canadian and French-Canadian, need to use the same version.
You might assume that you need to copy the same image into the
resource directory for both English-Canadian and French-Canadian, but
it's not true. Instead, you can save the image that's used for both as
icon_ca.png (any name other than icon.png) and put it in the default
res/drawable/ directory. Then create an icon.xml file in
res/drawable-en-rCA/ and res/drawable-fr-rCA/ that refers to the
icon_ca.png resource using the element. This allows you to
store just one version of the PNG file and two small XML files that
point to it. (An example XML file is shown below.)

Please refer this link for more clearity.

drawable mdpi/ldpi/hdpi should be drawable normal/small/large?

So for differnt screen sizes, should we use drawable small/medium/large?

You should use both types of qualifiers (e.g., res/drawable-large-mdpi/) as needed, for whichever densities you choose to ship. For images that do not need to change based on screen size, just use the density qualifier. For images that do need to change size based on screen size, also include a screen size qualifier, either the legacy ones (e.g., -large) or the newer ones (e.g., -sw600dp).

Explain the difference between drawable, drawable-ldpi, drawable-mdpi and drawable-hdpi

As the others have suggested, the Android online documentation has great articles on this. However, I'm going to try and list here some quick and helpful tips:

  1. Consider MDPI is 1. Then, LDPI is 0.75 and HDPI is 1.5. What that means is that if you have a drawable that is, say, 50x50 on a MDPI screen it will have to be ~37x37 on a LDPI screen and 75x75 on a HDPI screen, in order to appear at roughly the same physical size on each screen (i.e. 2cm if you put a ruler on the screen). Also, your computer screen is most probably MDPI, which is why it's recommended to start with MDPI drawables and then resize them: the physical size of the drawable will be very close between your computer screen and an MDPI Android device. If you view an HDPI drawable on your computer and on an HDPI device you will notice that it's much bigger (again, physically -- put a ruler on it style) on the PC screen.
  2. If you do not supply special drawables for each density, Android will scale the closest one available automatically.
  3. You should not consider the DPI of a device to have anything to do with screen size and/or number of pixels and/or resolution and/or aspect ratio. A device could be very small and have an HDPI screen or very large and have an LDPI screen. The whole point of this density-differentiation is to have things look the same size on all devices, not fit the same on all devices. For example, if a drawable fills the whole screen on one MDPI device do not expect it to do the same on another MDPI device. Also, do not expect to "see the same thing" on different DPI devices. Most HDPI devices actually have more space than lower DPI devices. For example, if a ListView can show 5 items on a MDPI device it might be able to show 6 items on an HDPI device, in spite of the fact that the ListView items have the same density-independent (i.e. 1.5 times larger on HDPI than on MDPI) height.

I might have gone a bit offtopic, but these are things I have learned in time by banging my head against them. Just trying to save someone else's headache :)

Is there a way to create xxhdpi, xhdpi, hdpi, mdpi and ldpi drawables from a large scale image?

I was using "Android Asset Studio". Now I am using IconKitchen, the successor to the Android Asset Studio, and a great new way to make highly customizable app icons for Android, iOS, web, Windows, Linux and Mac.

Android Drawable hdpi xhdpi mdpi ldpi concept

The folders without any qualifiers (layout, drawable, raw, values etc.) are the default folders. Android looks for each resource in them if it isn't found in the folders that qualify for that device. If you have a copy of any resource in them, you should never get a ResourceNotFound exception for that particular resource, unless the manufacturer introduces a bug into their ROM.



Related Topics



Leave a reply



Submit