drawable sizes for different screen sizes in android

16,707

Solution 1

You should usually avoid creating images for certain screen sizes to make them background, because there are thousands of different devices and you would have to create dozens of such images.

The first thing you need to be aware of is screen density.

Generally you create 3 to 5 images when not even looking at screen size: low (120 dpi), medium (160 dpi), high (240 dpi), extra high (320 dpi) and 2*extra high (480 dpi). These go into drawable-Xdpi folders, where X is one of l, m, h, xh, xxh.

Next thing when you want to have bigger images on bigger screens (bigger phones, small and big tablets), you may want to put images to folders like drawable-sw600dp-Xdpi. This is not a case for your phone.

Nexus 4 is a xhdpi 640x384 dp device, but you should not treat it differently than Samsung Galaxy S2 (hdpi 533x320 dp).

Create an image of smaller size for both phones and center it horizontally. E.g. 320x100 px for mdpi, 480x150 px for hdpi and 640x200 px for xhdpi (your phone).

Solution 2

With 1600+ android models even after they are categorized in few Screen size and a few DPI's its very difficult to manage layouts.. i suggest that you just concentrate on designing layouts w.r.t to screen size and then create views as Resizeable Views to neglect density effects.

Once you have created your layouts Resize the Views .. You can create a Custom View or resize on its onMeasure();

Solution 3

This is problem of Android Fragmentation and you just cannot deal with it perfectly as there is a several hundreds different devices. As colleague above wrote Nexus 4 has resolution -1280 x 768 so for sure res of image as equal as 960 x 720 is good choice. I'm even surprised that google suggest 640 x 480 for xhdpi, it's definitely too less.

So as I said you are not able to make perfect looking graphics for all existing devices. You should choose the most popular devices from every screen category(xhdpi,mdpi,ldpi ... etc) to cover the most important market share.

Solution 4

the screen resolution for Nexus is 1280x768 (http://www.google.com/nexus/4/specs/), resize the image to this resolution. In especial consideration some images can't handle the resolution and the image became disproportionately.

for interesting resolution calculator: http://members.ping.de/~sven/dpi.html

Share:
16,707

Related videos on Youtube

Fcoder
Author by

Fcoder

Updated on June 20, 2022

Comments

  • Fcoder
    Fcoder almost 2 years

    i have a problem in android development that bored me. my problem is screen size and dealing with that. specially i have some problems with images. for example i want to create a background image for my activity that i created in photoshop and my background image contains a "HELLO" word on it. but when i put it on drawable-xhdpi folder, it seems blurry and its not sharp!! my phone is a nexus 4 and according to Google documentation i create background image in 640 x 480 size.

    when i create background image in 960 x 720 size it seems better but not perfect. in this case my image file size is very high!

    but what is the standard way for this? please help me to solve this problem for ever. i read google documentation but its not solve my problem! http://developer.android.com/guide/practices/screens_support.html

    • Opiatefuchs
      Opiatefuchs almost 11 years
      I faced the same problems sometimes, because mdpi,ldpi,hdpi etc. is not only for a fixed screen size. There are many devices which got a similar, but not identic size, and they are one category. Using ImageView and ScaleType gaves me the best solution.
    • Lalith B
      Lalith B almost 11 years
      create a 9 patch with your text in the center and repeat the rest of the background. Have the 9patch for all possible DPI's

Related