[Android 資訊] Differences of px, sp, pt, dip, dp, in, and mm?
时间:2010-12-24 来源:FANTAISIE
It's an issue we will meet - what are the difference of px, sp, pt, dip, dp, in, and mm?
Here are the definitions:
px - Pixel
Independent points from devices corresponding to actual pixels on the screen. (e.g. HVGA: 320x480)
pt
Points - 1/72 of an inch
dip - Density-independent Pixel
It's an abstract unit that is based on the physical density relative to a 160 dpi screen. That is to say, one "dp" is one "px" on a 160 dpi screen. The ratio of dp-to-pixel changes with the screen density. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".
dp
Compiler recognize it as "dip".
sp - Scale-independent Pixel
It acts like an "dp" unit, but it can be also scaled by the user's font size preference that will be adjusted for both the screen density and preference.
It is recommend when trying specifying font sizes,
in -Inch
The size that is based on the physical size of the screen.
mm -Millimeter
The size that is based on the physical size of the screen.