| Refers to the actual pixels on the screen. |
Depending on the actual size of the screen in inches. |
Determined by the actual size of the screen. |
Based on the actual size of the screen, 1/72 of an inch, assuming a screen with a resolution of 72dpi |
An abstract unit based on on-screen physical density. These measurements are measured in relation to a 160 dpi screen. |
| The compiler only accepts px |
The compiler only accepts in (however this unit is not recommended because it may vary) |
The compiler takes mm, but not by default (takes sp) |
Not a familiar unit, used in old Android Programming, by Eclipse. Still, the compiler takes it. |
The Compiler accepts both “dip” and “dp,” |
| The actual physical present pixels of the screen is measured by its diagonal. Android combines all real screen sizes into four generic sizes for ease of use: small, standard, big, and extra-large. |
The actual screen estate which is available on the running device is accessible to the Android OS. |
The usual unit of measurement is millimeters, used like in everyday measurements. |
Similar to the dp unit, but scaled by the user’s font size selection. When choosing font sizes, it is suggested that you use this unit so that they are adjusted for both screen density and user choice. |
The dp-to-pixel ratio will alter with screen density, but not always in a straight proportion. However “dp” is more consistent with “sp.” |
| Can be used to determine the layouts and elements places on the layout. |
Can be used to scale the elements on the screen concerning the actual screen. |
Should not be used for setting and determining the layouts due to the variations possible. |
Can be used to design the layout just like px but is preferred less as compared to the other measurements. |
The “sp” here is only used for text; it should never be used for layout sizes. |
| px = dp * (dpi / 160) |
N/A (as the measurement is absolute) |
N/A (as the measurement is absolute) |
N/A (as the measurement is absolute) |
Density = sqrt((wp * wp) + (hp * hp)) / di |
Represented in terms of x*y. X is the horizontal axis, Y is the vertical. |
Represented in absolute digits and integers within as suffix |
Represented in absolute digits and integers within as mm |
Represented as pts or pt depending on the version of Android Studio you are using. |
Represented as simply ‘dp’ and to use with text use ‘sp’. |
| NOT density-independent |
Density Independent |
Density Independent |
Density Independent |
Density Independent |