That field is documented as being a bit mask:
http://developer.android.com/intl/fr/reference/android/content/res/Configuration.html#screenLayout

That means that it is one number, but different bits within the number
are being used to indicate different things. To check any particular
thing about it you can perform an and operation on it using the mask
of the part you want, then compare to the constants.

It sounds like you'd be better off in general using the equivalent of
density independent pixels anyway. Multiply your pixel measurements by
the density field in DisplayMetrics:
http://developer.android.com/intl/fr/reference/android/util/DisplayMetrics.html#density

And you'll get the same number as if you used dip:
http://developer.android.com/intl/fr/guide/practices/screens_support.html

It is also easy to check the width and height of the display in
pixels:
http://developer.android.com/intl/fr/reference/android/util/DisplayMetrics.html#heightPixels

If you wanted to cross the screen vertically in the same number of
steps no matter what the height, the number of pixels needed per step
for any particular height is easy to calculate.

If you are writing a game using GLSurfaceView you don't even have to
get the display size yourself, it is passed to you:
http://developer.android.com/intl/fr/reference/android/opengl/GLSurfaceView.Renderer.html#onSurfaceChanged%28javax.microedition.khronos.opengles.GL10,%20int,%20int%29

On Apr 4, 1:13 pm, Bevor <[email protected]> wrote:
> Hello,
> I tracked the behaviour of the different screen sizes when I increased
> the position of a graphic by 10 pixel. Unfortunately happened what I
> already thought. When the display is bigger, I'm able move a graphic a
> lot of times more to get to the bottom of the screen. So the ratio
> between the graphic and its environment is not correct anymore (so not
> 10 pixel as on normal screen) although the change of the graphic on
> the different screens looks correct (On big screen it is bigger, on
> small screens it is smaller). When I move the graphic from the top of
> the screen to the bottom, I can move that on 480x800 about 65 times,
> on 480x854 70 times, and on the 320x480 screen only about 25 times. So
> the target must be to calculate the right ratio so that 10 pixels on
> the small screen are 17 pixel (or sth. similar) on big screens. What
> approaches do I have to do that? I already thought about getting the
> value of res.getConfiguration().screenLayout to know if I have a
> small, normal, or big size to be able to calculate anyhow the right
> ratio, but this both seems to be pretty cumbersome and moreover I get
> values from res.getConfiguration().screenLayout I can't explain. I
> launched 6 emulator instances and got the following values from
> res.getConfiguration().screenLayout:
>
> 240x320 QVGA low density: 17
> 320x480 HVGA medium density: 18
> 480x854 WVGA high density: 34
> 480x800 WVGA high density: 34
> 240x400 WQVGA low density: 34
> 240x432 WQVGA low density: 266435490 (yes, I really get this value!)
>
> This approach seems to be useless because I cannot even distinguish
> between 480x854 and 480x800, much less of the last value which seems
> to be corrupt.
>
> How can I solve it to move a graphic on the different screens with the
> right ratio? How do game developers solve this when they support all
> screens?
>
> Regards.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to