Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

What is the difference between “px”, “dip”, “dp” and “sp” in android?

What is the difference between Android units of measure?

. px
. dip
. dp
. sp
by

3 Answers

RoliMishra
px
=>Pixels - corresponds to actual pixels on the screen.


dp or dip
=> Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".

sp
=> Scaleable Pixels OR scale-independent pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommended you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference. Note, the Android documentation is inconsistent on what sp actually stands for, one doc says "scale-independent pixels", the other says "scaleable pixels".
Sonali7
px stands for pixels and it refers to the actual pixels on the screen.

dp or dip stands for Density-independent Pixels. It is an abstract unit that corresponds to more or fewer pixels depending on the physical density.
1dp = 1px on mdpi

sp stands for Scaleable Pixels OR scale-independent pixels. This is like the dp unit, but it is also scaled by the user's font size preference. They are scaled when the Large Text option is turned on in Settings > Accessibility
1sp = 1dp
1sp = 1.2dp with accessibility Large Text
androidtuts
px = Pixel
dp & dip= Density-independent Pixels
SP= Scaleable Pixels

Login / Signup to Answer the Question.