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开机自动唤醒屏幕、打开锁屏页并启动app
  2. android 不同drawable文件对应的dpi值,和所放图片分辨率
  3. Android(安卓)屏幕保护程序制作及源码
  4. 分享 Android(安卓)手机屏幕录制并制作成 GIF 演示图片
  5. Android改变手机屏幕朝向的方法
  6. Android(安卓)屏幕旋转操作Demo
  7. Android官方技术文档翻译——Apk 拆分机制
  8. android中dip、dp、px、sp和屏幕密度
  9. android 屏幕保护

随机推荐

  1. What is Gradle
  2. Android(安卓): 录音实现之AudioRecord类
  3. Android(安卓)Gradle和ProGuard学习
  4. Android(安卓)4.4 Graphic系统详解(4)HWUI
  5. cocos2d-x for android:HelloWorld 解读
  6. Android(安卓)Studio开发手机APP(二)-利
  7. android 内存泄露之jni local reference
  8. 说说Android(安卓)两种为自定义组件添加
  9. Android:layer-list详解
  10. 使用Chrome远程调试Android移动端WebView