Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smallest Width for Galaxy S and Galaxy S2

I'm developing an Android Widget and need to differentiate between Galaxy S and Galaxy S2. I almost read everything about Screen sizes and densities articles. And I need, of course, to use the new qualifiers with the new qualifier Smallest Width. My problem is, that the sw320dp qualifier match for Galaxy S and also for Galaxy S2. But I need another layout for Galaxy S2, but cant find the right qualifier for it.

Definition of Galaxy S, Density 233

Screen Size in Pixels: 480 Pixel x 800 Pixel

Screen Size in dp: 329dp x 549dp (cause 1dp = 1pixel/(density/160)

-> so the qualifier sw320dp must match here. and yes it does

Definition of Galaxy S II, Density 218

Screen Size in Pixels: 480 Pixel x 800 Pixel

Screen Size in dp: 352dp x 587dp (cause 1dp = 1pixel/(density/160)

-> so the qualifier sw340dp must match here, but NO it doesnt

(Tested in emulator and on real device)

The drawables are not the problem, but my layout, especially the height and text sizes are different on these devices, so I really need a specific layout for them.

Anyone has an idea or more experience with it?

like image 698
user1013443 Avatar asked Dec 25 '12 12:12

user1013443


1 Answers

Screen density, as defined by the reference material is:

The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen. For simplicity, Android groups all actual screen densities into four generalized densities: low, medium, high, and extra high.

low = 120dpi med = 160dpi high = 240dpi xhi = 320dpi

So the Galaxy SII, with a real density of 218, gets assigned a "high" density of 240 in dp calculations. Thus the width of the screen in dp is 480/240*160 = 320.

This sucks, I agree. But it's how it works.

http://developer.android.com/guide/practices/screens_support.html

like image 88
CjS Avatar answered Sep 29 '22 13:09

CjS