How to calculate the pixel density (dp) of a device?

LittleFunny picture LittleFunny · Oct 1, 2013 · Viewed 25.4k times · Source

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.

Answer

codeslapper picture codeslapper · Feb 18, 2015

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