ppi is hardware
Pixels per inch is a physical property of the panel. Take the diagonal in pixels, the square root of width² plus height², and divide by the diagonal in inches. A 1080×2400 panel at 6.4 inches works out to about 401 ppi. Nothing the software does changes that number, and it is the honest measure of sharpness.
dpi is a software setting
Android does not use ppi directly. It snaps every panel to one of six density buckets — 120, 160, 240, 320, 480, 640 — choosing whichever is closest to the ppi. Our 401 ppi panel therefore reports 480 dpi, not 401. That reported value is what the resource system uses to pick drawables, and it is what adb shell wm density prints.
Crucially, dpi is mutable. Users can change display size in Settings, ROMs can ship their own default, and developers can override it per app. So “the dpi of a Pixel 7” is really “the dpi a Pixel 7 reports under a particular configuration”. That distinction matters when a bug only appears on one device.
dp is the layout unit
A dp is defined as 1/160 inch, so it converts to pixels using the scale factor dpi ÷ 160. At 480 dpi, one dp is three pixels. The value of this abstraction is physical consistency: a 48 dp touch target is roughly 7.6 mm on any correctly configured device, whether the panel is 320 dpi or 640 dpi.
Divide the physical resolution by the scale factor and you get the dp viewport — the size your layout actually sees. Two phones with completely different resolutions can land on the same dp viewport, which is exactly why a single layout can work across a huge range of hardware.
The practical rules
- Design and lay out in dp and sp, never in px, unless you are drawing to a canvas you measured yourself.
- When a layout looks wrong, check the reported density before you change your code — it is often a display-size setting.
- Do not derive dp width from the resolution alone; divide by the reported density.
- Test at least one 360 dp device and one sw600dp device, since those are the two layout regimes that matter.
To look up all three numbers for a specific phone, browse the device database. To compute them for a panel that is not listed, use the DPI calculator.