Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

drawable sizes for different screen sizes in android

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

like image 935
Fcoder Avatar asked Jun 23 '13 13:06

Fcoder


4 Answers

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).

like image 109
MaciejGórski Avatar answered Oct 07 '22 14:10

MaciejGórski


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();

like image 40
Quamber Ali Avatar answered Oct 07 '22 13:10

Quamber Ali


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

like image 1
MineScript Avatar answered Oct 07 '22 14:10

MineScript


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.

like image 1
Krzysiek Avatar answered Oct 07 '22 14:10

Krzysiek