Density-independent pixel (dp)
Definition
Density-independent pixels help Android interfaces appear similarly sized on displays with different pixel densities.
A dp is a virtual unit of measure for Android layouts. On a reference display with 160 dpi, one dp corresponds to one physical pixel; other pixel densities are converted accordingly. This makes dimensions less dependent on the actual number of display pixels.
Simply explained
A button should not become tiny on a sharp display just because more pixels fit there.
Why it matters in practice
Appropriate layout dimensions support usable surfaces on different Android devices and facilitate consistent spacing.
Example from business
Possible example: An app defines the spacing between controls in dp and checks the result on multiple display densities.
Limits and pitfalls
- dp is neither a printer point nor generally equal to a CSS pixel. For text, Android additionally considers user font size settings with sp.
Origin & history
The unit belongs to Android's density-independent layout system; physical pixels remain the actual display pixels.
Use in mid-sized companies
- Teams use appropriate layout and text units and test sizes, line breaks, and usability on different devices.
Frequently asked questions
Is a dp always a pixel?
No. This only applies at the reference density; at other densities, the number of pixels changes.
Sources
- Support different pixel densities. · Android Developers (o. J.): Support different pixel densities.
Editorially reviewed on: