Smallest Width for Galaxy S and Galaxy S2
Asked Answered
E

1

7

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?

Engagement answered 25/12, 2012 at 12:50 Comment(5)
afaik, the framework doesn't use the actual density but "rounds off" to the nearest of 120, 160, 240, 320px, corresponding to low, med, high and x-high. So both your devices would report sw=320. This can lead to irregular results -- I also have issues with this on Galaxy devicesCorridor
yes, thats excatly my experience as well....but even inside the emulator we cant make the setup for the real devices?Engagement
This hasn't anything to do with the emulator. It's a feature of the framework. You'll have the same problems on the actual deviceCorridor
a feature? well, when i cannot emulate a real device with the correct display, then thats not a feature for me.Engagement
You're misunderstanding me. You are emulating the real device correctly. The Android OS (not the emulator) does not "support" dpis that are not 120,160,240, or 320, so it takes the closest one. Link provided in answer.Corridor
C
5

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

Corridor answered 4/1, 2013 at 21:40 Comment(4)
I understand already what Android does...but well...fact is I cannot emulate a real Samsung Galaxy SII or SIII , the most used Android phones...this sucks and is really surprising me..Engagement
I think what you're missing is that even the real Galaxy SII will have a sw of 320dp, and NOT 340. So you are emulating the real device accuratelyCorridor
Fact is: It's not possible to emulate a real device. Only if a device has a densitiy exactly match with one of low, med, high or xdpi. Or how to setup the emulator for Galaxay Phones? I tried it all. Real device always looks very different.Engagement
That hasn't been my experience. I have the S2 emulated as 480x800,hdpi,normal & the S3 at 1280x720,xhdpi,normal. The screenshots from my emulator look pretty damn close to what users have sent me from their real devices. One comment though -- text and things on your computer monitor can seem hopelessly too large if you don't use the size scaling feature of the emulator. e.g. on my 22" monitor, I need to scale the emu display by 0.4-0.5 to make it the "actual" phone size. Even then, text can look comically large, but holding up my actual phone to the monitor convinced me that this is correctCorridor

© 2022 - 2024 — McMap. All rights reserved.