Question

What is the independent pixel density for a Galaxy s4?

I need it so I can have a qualifier sw???dp for that phone.

It would be great if you could explain how to calculate it.

Was it helpful?

Solution 2

Here you can find how to calculate sw???dp for every device you want.

Application Skeleton to support multiple screen

I think that instead of 96 x 5' (screen size) you should use these qualifiers: http://developer.android.com/design/style/devices-displays.html (160, 240, 320, 480). In this case of Galaxy S4, you get the good result, but if you try for example with a Nexus4 (4,7 ') you will get sw~272 instead of 380 as it should, and as happens in practice. This is the value you should use in your formula and you will get the right result.

OR

run this snippet code: (API 13+)

int sw = getResources().getConfiguration().smallestScreenWidthDp;

OTHER TIPS

Nobody answered the question: S4: Resolution 1080 x 1920 pixels (~441 ppi pixel density) per gsmarena formula: px = dp * (dpi / 160) from Google's article on "Supporting multiple screens". Therefore: dp = px / (dpi / 160). So, shortest width (sw) = 1080/(441/160) = 391

As also stated here: Use size and density-specific resources problems in Android app design

Galaxy s4 has a density of about ~441ppi i.e so the scale factor will come around 441/160=2.75. which is much higher than hdpi(1.5) or xhdpi (2.0).Put your fonts xml in values-xxhdpi folder.

You can also have a look here look here for any further queries.

You can always find it in gsmarena.

For other unknown phones here's the formula for calculating the dpi:

dpi = ( square_root ( horizontal_pixels ^ 2 + vertical_pixels ^ 2 )) / ( screen_size )

In the case of galaxy s4:

  • horizontal pixels = 1080
  • vertical pixels = 1920
  • screen size = 5.0

Then

dpi = ( square_root ( 1080 ^ 2 + 1920 ^ 2 )) /  5.0

dpi = ( square_root ( 1166400 + 3686400 )) /  5.0

dpi = ( square_root ( 4852800 )) /  5.0

dpi = ( 2202.91 ) /  5.0

dpi = 440.5

dpi = 441 dpi
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top