14

I would like to create a background image for different resolutions in Android. So I need the values (in pixel) for ldpi, mdpi, hdpi,xhdpi and xxhdpi. It is important that the image will not be blurred.

I have already read the Documentation about multiple screen support but there are sizes in dp instead of pixel.

vbence
  • 20,084
  • 9
  • 69
  • 118
JavaForAndroid
  • 1,111
  • 2
  • 20
  • 42
  • you have variety of resolutions in android devices. If you do it this way, you will have to create hundreds of images – mihail Nov 09 '13 at 11:07
  • I think you can dynamically calculate window size and set background accordingly. – Prinz Km Feb 02 '15 at 09:36

5 Answers5

72

Try follow below android icon graphy size reference for various device screen resolutin.

                            ldpi     mdpi     hdpi     xhdpi    xxhdpi     xxxhdpi
Launcher And Home           36*36    48*48   72*72    96*96    144*144    192*192
Action Bar And Tab          24*24    32*32   48*48    64*64    96*96      128*128
Notification                18*18    24*24   36*36    48*48    72*72      96*96
Background                  320*426  320*470 480*640  720*1280 1080*1920  1440*2560
Haresh Chhelana
  • 24,720
  • 5
  • 57
  • 67
  • 7
    can you please tell the source of this information. The background sizes does not seem to be applying correctly on actual devices – bhaskarc Feb 12 '14 at 12:29
  • this are designed for phones you can find and 720 x 1280 phone from 4.2 inches to tablet of 10 inches. so in fact you have to use different background images for phones, phablets, tablets 7 and 10 – Pedro Teran Sep 30 '15 at 20:07
  • I've come independently to almost the same measurements except for two small differences. If you scale according to the densities correctly you should end up with 360 width for mdpi and 540 width for hdpi. – Galya Jul 20 '16 at 19:02
  • And what number should be the resolution? For example `1440` is the width and `2560` is the height. Ok, so what about the resolution? – Shafizadeh Apr 07 '17 at 14:23
9

there is no full list of screen resolutions, there are no fixed values in pixels for ldpi, mdpi, hdpi,xhdpi and xxhdpi. Every android device may have different resolution. If you want to fill all resolutions you will have to create too many images. If you put them in your app, it will make the app size huge. Maybe a better approach is to use composite image for background.

mihail
  • 2,173
  • 19
  • 31
8

According to android documentation

mdpi is baseLine size

enter image description here

we can use it to measure all other scales , that mean if mdpi (scale 1) equal 1 xhdpi (scale 2) should equal 2 , multiplay mdpi sizes in scale value

all sizes width x height in pixel

xxxhdpi: 1280x1920 px  // 4x
xxhdpi : 960x1440 px   // 3x
xhdpi  : 640x960 px    // 2x
hdpi   : 480x800 px    // 1.5 x at least 480x720  
mdpi   : 320x480 px    // baseline = 1x
ldpi   : 240x360 px    // .75 x

** notice I add xxhdpi with 3.0x scale to image*

userM1433372
  • 5,345
  • 35
  • 38
Mina Fawzy
  • 20,852
  • 17
  • 133
  • 156
7
  • xhdpi: 640x960 px
  • hdpi: 480x800 px
  • mdpi: 320x480 px
  • ldpi: 240x320 px
Matthew Rapati
  • 5,648
  • 4
  • 28
  • 48
Roshaan Nayyar
  • 133
  • 1
  • 2
  • 6
0

i think it is rather easy to convert the DP into pixels in andorid java i am achieving this with this function that i created

int getPixels(Context context, float dp) {
    return (int) (context.getResources().getDisplayMetrics().density * dp + .5f);
}

hopefully this is helpful for people, and kindly do share your views on it, as i would like to get this conversion as accurate as possible, thankyou

Syed Naeem
  • 681
  • 8
  • 17