http://sunlong.iteye.com/blog/745365

转载自:

Historically, programmers always designed computer interfaces in terms of pixels. For example, you mightmake a field 300 pixels wide, allow 5 pixels of spacing between columns, and define icons 16-by-16 pixels in size. The problem is that if you run that program on new displays with more and more dots per inch (dpi), the user interface appears smaller and smaller. At some point, it becomes too hard to read. Resolution-independent measurements help solve this problem.
Android supports all the following units:
• px (pixels): Dots on the screen.
• in (inches): Size as measured by a ruler.
• mm (millimeters): Size as measured by a ruler.
• pt (points): 1/72 of an inch.
• dp (density-independent pixels): An abstract unit based on the density of the screen. On a display with 160 dots per inch, 1dp = 1px.
• dip: Synonym for dp, used more often in Google examples.
• sp (scale-independent pixels): Similar to dp but also scaled by the user’s font size preference.
To make your interface scalable to any current and future type of display, I recommend you always use the sp unit for text sizes and the dip unit for everything else. You should also consider using vector graphics instead of bitmaps

如果英文不想看,看下面:

px:是屏幕的像素点

in:英寸

mm:毫米

pt:磅,1/72 英寸

dp:一个基于density的抽象单位,如果一个160dpi的屏幕,1dp=1px

dip:等同于dp

sp:同dp相似,但还会根据用户的字体大小偏好来缩放。

建议使用sp作为文本的单位,其它用dip

更多相关文章

  1. Android(安卓)draw Rect 坐标图示
  2. Android(安卓)Launcher3 设置壁纸请教
  3. Android之ViewFlipper的用法
  4. Android获得控件在屏幕中的绝对坐标
  5. 禁用Android底部虚拟按键
  6. Android开发笔记4----应用程序组成
  7. 手机锁屏后再解锁保存activity状态
  8. Android获取屏幕高度
  9. unity游戏在安卓按home或者锁屏键后不能后台运行的结局方案

随机推荐

  1. Android(安卓)-- View
  2. Error while executing process /Users/x
  3. Android(安卓)使用ORMLite 操作数据库
  4. Android(安卓)使用的Project build.gradl
  5. [译]ANDROID Porting系列
  6. Android双击事件拦截方法
  7. Android(安卓)深入研究SQLite实例(六)
  8. Android(安卓)权限管理 EasyPermissions
  9. Android底层开发(一)Android源码编译
  10. Android(安卓)9.0 版本以上,多进程访问对W