Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

drawable vs. drawable-ldpi/drawable-mdpi

Tags:

android

All the Android docs mention the "drawable" directory. However, when I create an Android project in Eclipse, it doesn't create a "/res/drawable" directory, but it does create "/res/drawable-ldpi" and "/res/drawable-mdpi". I imagine those have something to do with pixel resolution, but what's exactly going on here? When I've stepped through the tutorials, I've manually created a "drawable" directory and put my resources in there, but did I need to? Do references to "/res/drawable/" work if only "drawable-{l|m}dpi" are present?

like image 438
David M. Karr Avatar asked Dec 01 '10 17:12

David M. Karr


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 Xxhdpi?

Drawable xhdpi 官网 Compatible with IntelliJ IDEA (Ultimate, Community, Educational), Android Studio and 13 more. Quickly and easily convert images into images of various densities (LDPI, MDPI, HDPI, XHDPI, XXHDPI, XXXHDPI) used by Android.

What is RES 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.

What is Xhdpi?

Hdpi is a 1.5:1, and can be thought of as a HD (high-definition) display. And xhdpi is 2:1, much like Apple retina displays. . The normal mdpi is based on a 160 dpi screen, which again is the same as a single pixel unit in your graphics software.


3 Answers

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

like image 131
Mark B Avatar answered Sep 17 '22 17:09

Mark B


Yes, you need to make a default /res/drawable directory in Eclipse.

If you want to use the -hdpi/-mdpi/-ldpi folders, then you need to make separate xml layouts to refer to them.

http://developer.android.com/guide/practices/screens_support.html

like image 35
Lionel Avatar answered Sep 20 '22 17:09

Lionel


I assume it has something to do with how you generated the Android project. Typically mine creates an hdpi, mdpi, and ldpi folder. Basically, "drawable" is the default. If you have all of your resources in the hdpi folder, and try to run it on an ldpi device, I believe you will get an exception of some kind (I have not tested this, but I believe this to be the case). A detailed explanation of what happens without default resources is explained here.

You should keep a default collection of resources in the main "drawable" folder (that yes, you may have to create manually) just to be on the safe side, and to ensure compatibility with older versions of Android. Android will check the specific density folders first, but will roll back to the default drawable folder if it cannot find that specific resource in that density.

like image 41
Kevin Coppock Avatar answered Sep 16 '22 17:09

Kevin Coppock