Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : Understanding drawable folder

Tags:

I have an image with dimensions 250*70 pixels under drawable folder (I'm just starting out in Android development, so i created drawable folder in res) and I have the same image with higher dimensions in drawable-large folder; but the image is not looking as I expected.

Can anyone explain the reason behind/purpose of 3 drawable folders?

Where should I store my image so that it displays properly in both modes (landscape & portrait) and in all the mobiles (including tablets)?

I want my image to scale dynamically to the size of the device screen.

Can anyone share your views or links to search ?

like image 770
SANDHYA Avatar asked May 09 '12 13:05

SANDHYA


People also ask

What is the use of drawable folder in Android?

A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon . There are several different types of drawables: Bitmap File.

What are the drawable folders?

For current phone projects, every project should have at least 4 folders for drawables (drawable-ldpi, drawable-mdpi, drawable-hdpi and drawable-xhdpi). This allows images to be crisp and clear for all Android devices, as they won't need to be stretched.

How do I make a drawable Xxhdpi folder?

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 .


2 Answers

The folder names need to be :

  • /drawable-ldpi For low density screens
  • /drawable-mdpi For medium density screens
  • /drawable-hdpi For high resolution screens
  • /drawable-xhdpi For extra high resolution screens

/drawable should be reserved for assets that you either (1) don't care about which device or for (2) xml drawable assets

Then on top of that you can provide different resources based on configuration by using config qualifiers, you can read all about it here http://developer.android.com/guide/topics/resources/providing-resources.html

for instance, you can have high resolution assets for landscape with a folder

  • /drawable-land-hdpi

Hope that helps

like image 149
Ian Warwick Avatar answered Oct 07 '22 17:10

Ian Warwick


By default Android maintain three folders for the images with different resolution reason behind it is the use or the resolution of the Android Device on which the application gonna execute.

hdpi image folder maintain images for the Android Broad Screen set or Android Phones with the Higher resolution.

ldpi for Lower images quality which supports by the earlier sets of the android

mdpi for medium images support xhdi images folder for devices with maximum resolution.

Android OS select the image it self by checking the compatible device and its resolution.

Hope it helps. Accept if you get your explanation.

like image 28
user1160020 Avatar answered Oct 07 '22 17:10

user1160020