tags:

views:

35

answers:

1

I am working on an application based on Galaxy S at the moment. I know that Galaxy S is 480 px wide and 800 px tall, but how much is that in DP?

Lets say if I want to have two Layout side by side, I'll have them setting to 240 px. But how do I know what value I should use in DP unit?

+1  A: 
The conversion of dip units to screen pixels is simple: pixels = dips * (density / 160). For example, on 240 dpi screen, 1 dip would equal 1.5 physical pixels. Using dip units to define your application's UI is highly recommended, as a way of ensuring proper display of your UI on different screens.

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

[edit] I just had to used this. Using the DisplayMetrics.density returns only 0.75, 1 and 1.5. Use DisplayMetrics.densityDpi instead or change the math to pixels = dips * DisplayMetrics.density

WarrenFaith
How did I missed that! Thanks a lot :)
RobGThai