Droid10

Android DPI calculator

Given a panel's pixel resolution and diagonal size, this works out the physical ppi, the density bucket Android will select, the scale factor and the logical dp viewport your layout receives.

Panel

Result

Pixels per inch
411.2
Android density
480 dpi (xxhdpi)
Scale factor
3.00×
Logical viewport
360 × 800 dp
Diagonal pixels
2,632
Physical size
2.63 × 5.84 in

How the calculation works

The diagonal in pixels comes from Pythagoras: the square root of width² plus height². Dividing that by the diagonal in inches gives ppi. Android then snaps that continuous value to the nearest density bucket, and the bucket divided by 160 is the scale factor. Finally, physical pixels divided by the scale factor gives the dp viewport.

The step people miss is the snapping. A panel measuring 401 ppi does not use a 2.5× scale; it uses 480 dpi at 3×, because 480 is the nearest bucket. That is why the dp viewport is usually a rounder number than the raw division would suggest, and why devices at 400 ppi and 460 ppi report identical layouts.

The Android density buckets

BucketDensityScale1 dp =Typical use
ldpi120 dpi0.75×0.75 pxLegacy low-density panels
mdpi160 dpi1×1 pxOld tablets, some TVs
hdpi240 dpi1.5×1.5 pxBudget 720p-era phones
xhdpi320 dpi2×2 px720p and early 1080p phones
xxhdpi480 dpi3×3 pxVirtually all modern phones
xxxhdpi640 dpi4×4 pxHigh-density flagships

Frequently asked

How is the density bucket chosen?

Android picks the density bucket whose dpi is numerically closest to the panel's physical ppi. The buckets are fixed at 120, 160, 240, 320, 480 and 640 dpi, so a panel measuring 430 ppi resolves to xxhdpi at 480, while a 200 ppi panel resolves to hdpi at 240. This rounding is why two devices with quite different ppi can share a layout.

Why does the calculator show a different dpi than my phone reports?

Because your phone's reported density is a software setting, not a hardware measurement. Many ROMs deliberately report a lower density than the panel's ppi, and users can change it themselves. Run 'adb shell wm density' to see the value your device actually uses, then enter that into the converter instead of relying on the panel spec.

What is the dp viewport used for?

The dp viewport is the size your layout actually gets. It is how you decide whether a device falls into Android's compact, medium or expanded window size class, and therefore whether your two-pane layout will run. It is computed by dividing the physical pixels by the scale factor.