android dimension 单位,Android Dimension

1、Android中单位介绍

根据官网介绍(https://developer.android.com/guide/topics/resources/more-resources.html#Dimension),Android中可用单位有:

dp(Density-independent-Pixels);

An abstract unit that is based on the physical density of the screen.

基于物理屏幕密度的抽象单位。

sp(Scale-independent-Pixels);

This is like the dp unit, but it is also scaled by the user's font size preference.

和dp一样,但是还根据用户选择的字体大小选项缩放。

pt(Points);

1/72 of an inch based on the physical size of the screen, assuming a 72dpi density screen.

表示在屏幕上的1/72英寸,也是72屏幕密度。

(dpi:dots per inch)

px(Pixels);

Corresponds to the actual pixels on the screen.

in(Inches);

英寸

mm(MiliMeters);

毫米

2、Android中常用

Android中表示长度、宽度常用dp,字体大小常用sp。

因为这两个不是实际单位,会随着屏幕密度变化而变化,所以对于不同屏幕的适配很方便。

3、dp、sp、pt转换

px = (density/160)dp.

在160dpi下,1dp几乎等于1px,随着屏幕密度的变化,dp与sp的比例也随之缩放。

在160dpi下,

1dp = 1px;

1sp = 1px;

1pt = 72dpi;

1pt = 2.22sp.     【1in有160px(dp/sp),1pt = 1/72in(72dpi) ——> 1pt = 2.22sp】

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值