Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2019-09-27:getDimension、getDimensionPixelOffset 和 getDimensionPixelSize 三者的区别? #156

Open
Moosphan opened this issue Sep 27, 2019 · 3 comments

Comments

@Moosphan
Copy link
Owner

No description provided.

@zoushaohua
Copy link

getDimension()返回的float绝对尺寸,getDimensionPixelOffset返回取整绝对尺寸 int类型,getDimensionPixelSize四舍五入返回int类型,狗头+n

@aositeluoke
Copy link

相同点
单位为dp/sp时,都会乘以density,单位为px则不乘
不同点
1、getDimension返回的是float值
2、getDimensionPixelSize,返回的是int值,float转成int时,四舍五入
3、getDimensionPixelOffset,返回的是int值,float转int时,向下取整(即忽略小数值)

@mlinqirong
Copy link

getDimension返回的是float值
getDimensionPixelSize返回的是四舍五入后的int值
getDimensionPixelOffset返回的是去掉后面小数点的int值

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants