119

I have a background that I need fit in all screen sizes. I have three folders, hdpi, ldpi and mdpi for drawables, but in the emulator there isn't any referense to what resolution hdpi is and what mdpi and ldpi are.

0

4 Answers 4

141

You should read Supporting multiple screens. You must define dpi on your emulator. 240 is hdpi, 160 is mdpi and below that are usually ldpi.

Extract from Android Developer Guide link above:

320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).  
480dp: a tweener tablet like the Streak (480x800 mdpi).  
600dp: a 7” tablet (600x1024 mdpi).  
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
4
  • 1
    I put images in hdpi ldpi and mdpi folder, but when im running a QVGA emulator it must use ldpi but it resizes my hdpi images and this looks not as good as it should be
    – artouiros
    Commented May 29, 2011 at 9:34
  • and what is the screen resolution for this QVGA emulator?
    – evilone
    Commented May 29, 2011 at 9:39
  • 1
    i mean screen size in pixels.
    – evilone
    Commented May 29, 2011 at 9:46
  • Is this broken? I have a pretty old HTC phone of normal "hand size", but it has a DPI of 480. It is NOT a tablet.
    – Jonny
    Commented Aug 25, 2015 at 6:35
78

UPDATE: 30.07.2014

If you use Android Studio, make sure you have at least 144x144 resource and than use "FILE-NEW-IMAGE ASSET". Android Studio will make proper image files to all folders for you : )


As documentation says, adjust bitmaps as follows:

Almost every application should have alternative drawable resources for different screen densities, because almost every application has a launcher icon and that icon should look good on all screen densities. Likewise, if you include other bitmap drawables in your application (such as for menu icons or other graphics in your application), you should provide alternative versions or each one, for different densities.

Note: You only need to provide density-specific drawables for bitmap files (.png, .jpg, or .gif) and Nine-Path files (.9.png). If you use XML files to define shapes, colors, or other drawable resources, you should put one copy in the default drawable directory (drawable/).

To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8 scaling ratio between the four generalized densities. For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screen (the size for a launcher icon), all the different sizes should be:

36x36 for low-density (LDPI)

48x48 for medium-density (MDPI)

72x72 for high-density (HDPI)

96x96 for extra high-density (XHDPI)

144x144 for extra extra high-density (XXHDPI)

192x192 for extra extra extra high-density (XXXHDPI)

7
  • 2
    @Michal: XXHDPI should be 180x180 and the missing XXXHDPI is 192x192, according to this link.
    – ChuongPham
    Commented Sep 24, 2014 at 15:15
  • Thank you . I searched for this a lot. It helped me. +1
    – Mohammad
    Commented Nov 23, 2015 at 18:28
  • 36x36,48x48,72x72 are all of these in pixels?? So if I wanna create icons, it will be 36px width X 36px height?? Commented Feb 9, 2016 at 7:39
  • @LeonardoDaCodinchi Yes. I recommend you read stackoverflow.com/a/2025541/5127934 Commented Aug 13, 2016 at 12:38
  • XHDPI 96 * 96 but XXHDPI WILL BE 144 * 144. Commented Dec 11, 2016 at 8:03
9

The documentation is quite sketchy as far as definitive resolutions go. After some research, here's the solution I came to: Android splash screen image sizes to fit all devices

It's basically guided towards splash screens, but it's perfectly applicable to images that should occupy full screen.

8

Check out this awesome converter. http://labs.rampinteractive.co.uk/android_dp_px_calculator/

Not the answer you're looking for? Browse other questions tagged or ask your own question.