定义于:
http://developer.android.com/reference/android/widget/TextView.html#attr_android:width
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).
px - 像素,可以理解为屏幕上的绝对度量
dp - 设备独立像素,相当于一种相对度量,出于设备兼容性的考虑,使用dp比px有更好的显示效果.见下文:
The reason for dip to exist is simple enough. Take for instance the T-Mobile G1. It has a pixel resolution of 320x480 pixels. Now image another device, with the same physical screen size, but more pixels, for instance 640x480. This device would have a higher pixel density than the G1.
—If you specify, in your application, a button with a width of 100 pixels, it will look at lot smaller on the 640x480 device than on the 320x480 device. Now, if you specify the width of the button to be 100 dip, the button will appear to have exactly the same size on the two devices.
sp - 基于字体大小的固定比例的像素,没有使用过这种度量。 根据文字上的理解,这也是一种相对度量单位,是为了适应不同的字体而设计的(与dp适应不同的设备宽高相对应)
in - 英寸,绝对度量单位
mm - 千分米,绝对度量单位。