转换像素用上 [英] Convert pixels to sp
本文介绍了转换像素用上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我所需要的电流 TEXTSIZE
的的TextView
在 SP $ C $的C>单位。
I need the current TextSize
of the TextView
in sp
units.
但 getTextSize()
返回像素大小
。那么,有没有办法将转换为像素SP
?
But getTextSize()
returns the size in pixels
. So is there a way to convert pixels to sp
?
推荐答案
请参见 DisplayMetrics 类,它有一个 densityDpi()
和 scaledDensity()
。
See the DisplayMetrics class, it has methods for densityDpi()
and scaledDensity()
.
这篇关于转换像素用上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文