74

Study android, now I've some images to put into drawable dirs (hdpi/ldpi/mdpi/xhdpi). I read a lot but again I don't understand. Which size should be an image for every directories?

9 Answers 9

157

Hope this will help...

mdpi is the reference density -- that is, 1 px on an mdpi display is equal to 1 dip. The ratio for asset scaling is:

ldpi | mdpi | hdpi | xhdpi | xxhdpi | xxxhdpi
0.75 | 1    | 1.5  | 2     | 3      | 4

Although you don't really need to worry about tvdpi unless you're developing specifically for Google TV or the original Nexus 7 -- but even Google recommends simply using hdpi assets. You probably don't need to worry about xxhdpi either (although it never hurts, and at least the launcher icon should be provided at xxhdpi), and xxxhdpi is just a constant in the source code right now (no devices use it, nor do I expect any to for a while, if ever), so it's safe to ignore as well.

What this means is if you're doing a 48dip image and plan to support up to xhdpi resolution, you should start with a 96px image (144px if you want native assets for xxhdpi) and make the following images for the densities:

ldpi    | mdpi    | hdpi    | xhdpi     | xxhdpi    | xxxhdpi
36 x 36 | 48 x 48 | 72 x 72 | 96 x 96   | 144 x 144 | 192 x 192

And these should display at roughly the same size on any device, provided you've placed these in density-specific folders (e.g. drawable-xhdpi, drawable-hdpi, etc.)

For reference, the pixel densities for these are:

ldpi  | mdpi  | hdpi  | xhdpi  | xxhdpi  | xxxhdpi
120   | 160   | 240   | 320    | 480     | 640
43
MDPI - 32px
HDPI - 48px
XHDPI- 64px

This Cheat Sheet might be handy for you. check the image :-)

image

4
  • 1
    That image you shared is fantastic! Thank you! I've been searching for a good explanation of sizing, and now my search is over. May 28, 2014 at 21:20
  • "Spacing between elements = 8dp" any official source/link? Sep 13, 2016 at 23:43
  • 1
    Thanks @Rafique, but I'm confuse about of the another icons dimensions. Mar 4, 2017 at 5:19
  • 1
    valuable content for design guidelines in single frame Jul 20, 2022 at 4:23
15

I have a full explanation already posted here

Basically, General guidelines for designing images are:

ldpi is 0.75x dimensions of mdpi
hdpi is 1.5x dimensions of mdpi
xhdpi is 2x dimensinons of mdpi

Usually, I design mdpi images for a 320x480 screen and then multiply the dimensions as per the above rules to get images for other resolutions.

Please refer to the full explanation for a more detailed answer.

10
  • Posible dup of your own answer
    – wtsang02
    Jan 17, 2013 at 15:12
  • 1
    I guess your concept of "brief" is different than mine. This is a comprehensive answer, and well done. Great explanation (this concept is hard!).
    – Booger
    Jan 17, 2013 at 15:12
  • @wtsang02 It is a dup. The OP seems to be new so I thought I'd post it again for convenience. Jan 17, 2013 at 15:13
  • 1
    @Anup Cowkur thanks for the answer! A question: if I've a source image (i.e. 1600x960 size 47,3Kb) which size should have to put it on mdpi?
    – Max Asura
    Jan 17, 2013 at 16:01
  • 1
    @rbarriuso yes. xxhdpi is 480dp which is 3x of mdpi. Oct 4, 2013 at 12:55
6

See the image for reference :- (Soruce :- Android Studio-Image Assets option and Android Office Site )

enter image description here

1
  • 1
    Thanks @pravin, but I'm confuse about of the another icons dimensions. Mar 4, 2017 at 5:10
4

Tablets supports tvdpi and for that scaling factor is 1.33 times dimensions of medium dpi

    ldpi | mdpi | tvdpi | hdpi | xhdpi | xxhdpi | xxxhdpi
    0.75 | 1    | 1.33  | 1.5  | 2     | 3      | 4

This means that if you generate a 400x400 image for xxxhdpi devices, you should generate the same resource in 300x300 for xxhdpi, 200x200 for xhdpi, 133x133 for tvdpi, 150x150 for hdpi, 100x100 for mdpi, and 75x75 for ldpi devices

3

low dpi is 0.75x dimensions of medium dpi

high dpi is 1.5x dimensions of medium dpi

extra high dpi is 2x dimensinons of medium dpi

It's a good practice to make all the images in vector based format so you can resize them easily using a vector design software like Illustrator etc..

1
  • If you do use vector you still need to look at the bitmap output and probably tweak it so you don't get blurred edges where you need sharp ones! (e.g. the edge of a button might hit a pixel boundary and be nice and sharp at 1x but the edge will be on 50% between two pixels at 0.75X and look muddied). Personally I like using a bitmap at 2x making sure any edges I want to be sharp are on a multiple of 8 pixel boundary(you can add a grid in Photoshop), then scale the image to 0.75x, 1x, and 1.5x(0.75x will have sharp edges every 3 pixels, 1x will use 4 pixels, and 1.5x use 6 pixels).
    – Gabe
    Jan 15, 2014 at 17:44
1

As of Octoer 2020, the dimensions for Launcher, ActionBar/Tab and Notification icons are:

enter image description here

A very good online tool to generate launcher icons : https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html

0

you can use Android Asset in android studio , and android Asset will give you image in this size as a drawable and the application will automatically use the size based on screen of device or emulate

0
0

Not just tab icons, notification and launcher lives an app. I was confused about the sizes of the other icons used for different situations in the app.

I'm using 32px mdpi (Action Bar icons) dimensions and I cannot say if it would be correct.

mdpi 32px

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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