0
px
Pixels - corresponds to actual pixels on the screen.
像素 - 对应于屏幕上的实际像素。
in
Inches - based on the physical size of the screen. 1 Inch = 2.54 centimeters
英寸 - 基于屏幕的物理尺寸。 1英寸= 2.54厘米
pt
Points - 1/72 of an inch based on the physical size of the screen.
点数 - 基于屏幕物理尺寸的1/72英寸。
dp or dip
dp或dip
Density Independent Pixel, it varies based on screen density . In 160 dpi screen, 1 dp = 1 pixel. Except for font size, use dp always
密度独立像素,它根据屏幕密度而变化。在160 dpi屏幕中,1 dp = 1像素。除字体大小外,请始终使用dp
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".
密度无关像素 - 基于屏幕物理密度的抽象单元。这些单位相对于160 dpi的屏幕,因此一个dp是160 dpi屏幕上的一个像素。 dp与像素的比率将随着屏幕密度而变化,但不一定是成正比的。注意:编译器同时接受“dip”和“dp”,但“dp”更符合“sp”。
sp
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.
与比例无关的像素 - 这与dp单位类似,但它也可以通过用户的字体大小首选项进行缩放。建议您在指定字体大小时使用此单位,以便根据屏幕密度和用户偏好调整它们。
有关更多信息Android开发人员文档:
或点击这里