当前位置:网站首页>Android kotlin SP DP to PX
Android kotlin SP DP to PX
2022-06-22 21:35:00 【Too handsome to go out】
Android kotlin sp dp turn px
Code
/** * According to the resolution of the phone sp Turn into px( Pixels ) */
inline val Double.sp: Int get() = run {
toFloat().sp
}
inline val Int.sp: Int get() = run {
toFloat().sp
}
inline val Float.sp: Int get() = run {
val scale: Float = Resources.getSystem().displayMetrics.scaledDensity
return (this * scale + 0.5f).toInt()
}
/** * According to the resolution of the phone dp Turn into px( Pixels ) */
// Examples of use 10.dp
inline val Double.dp: Int get() = run {
return toFloat().dp
}
inline val Int.dp: Int get() = run {
return toFloat().dp
}
inline val Float.dp: Int get() = run {
val scale: Float = Resources.getSystem().displayMetrics.density
return (this * scale + 0.5f).toInt()
}
边栏推荐
- [142. circular linked list II]
- 《跟唐老师学习云网络》 - OpenStack网络实现
- las 点云创建网格
- NBA playoff match chart
- 2022年A特种设备相关管理(电梯)考题及模拟考试
- 【链表中倒数第k个结点】
- When the AUX1 or aux2 channel is used in Jerry's aux mode, the program will reset the problem [chapter]
- Differences between watch, computed and methods
- Fegin的解析
- 2022 chemical automation control instrument examination exercises and online simulation examination
猜你喜欢
随机推荐
第030讲:文件系统:介绍一个高大上的东西 | 课后测试题及答案
kali2021安装RTL8188GU无线网卡[TL-WN726N]驱动
[redis]redis persistence
PlainSelect. getGroupBy()Lnet/sf/jsqlparser/statement/select/GroupByElement;
解决phpstudy中mysql无法启动,与本地安装的mysql冲突
DACL output on Jerry's hardware, DAC output sound of left and right channels [chapter]
One line of code binds swiftui view animation for a specific state
513. find the value in the lower left corner of the tree / Sword finger offer II 091 Paint the house
Use Charles to capture packets
[21. merge two ordered linked lists]
引入稀疏激活机制!Uni-Perceiver-MoE显著提升通才模型的性能
第028讲:文件:因为懂你,所以永恒 | 课后测试题及答案【无标题】
Watch,computed和methods的区别
快速排序模板 & 注意事项
How to operate redis on the IntelliJ idea database console
微信小程序批量提交审核
杰理之AUX 模式使用 AUX1或者 AUX2通道时,程序会复位问题【篇】
建立自己的网站(12)
杰理之开启四声道通话近端卡顿问题【篇】
Apple Objective-C source code




![kali2021安装RTL8188GU无线网卡[TL-WN726N]驱动](/img/29/8dd188cc4e909562862b5f2c57c898.png)




![[cm11 linked list splitting]](/img/66/6ac3f78db20ec7f177b88c88028dde.png)