Be Smart

FANTAISIE

SmartPhone - iPhone, iPad, Android

导航

[Android 資訊] Differences of px, sp, pt, dip, dp, in, and mm?

When we start be build an UI, or make definition of the dimensions,

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 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.

posted on 2010-12-24 12:32  FANTAISIE  阅读(442)  评论(0编辑  收藏  举报