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
| Bucket | Density | Scale | 1 dp = | Typical use |
|---|---|---|---|---|
| ldpi | 120 dpi | 0.75× | 0.75 px | Legacy low-density panels |
| mdpi | 160 dpi | 1× | 1 px | Old tablets, some TVs |
| hdpi | 240 dpi | 1.5× | 1.5 px | Budget 720p-era phones |
| xhdpi | 320 dpi | 2× | 2 px | 720p and early 1080p phones |
| xxhdpi | 480 dpi | 3× | 3 px | Virtually all modern phones |
| xxxhdpi | 640 dpi | 4× | 4 px | High-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.