当前位置:网站首页>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()
}
边栏推荐
- 78- several methods to solve SQL performance problems without changing code in production system
- 53页智慧校园智能化系统设计方案(附下载)
- ACM. HJ24 合唱队 ●●
- List of outstanding talents: no crystal vibration, one drag, eight burn and upgrade [chapter]
- How to operate redis on the IntelliJ idea database console
- 53 page intelligent campus intelligent system design scheme (download attached)
- [redis]集群与常见错误
- 【ICML2022】利用虚拟节点促进图结构学习
- Jerry's near end tone change problem of opening four channel call [chapter]
- 第019讲:函数:我的地盘听我的 | 课后测试题及答案
猜你喜欢

Cannot re-register id: PommeFFACompetition-v0问题解决
How to operate redis on the IntelliJ idea database console

鸿蒙第三次培训

Laravel+ pagoda planning task
![List of outstanding talents: no crystal vibration, one drag, eight burn and upgrade [chapter]](/img/6c/333bc95fe390234d3d06043e4bded1.png)
List of outstanding talents: no crystal vibration, one drag, eight burn and upgrade [chapter]
![[redis]redis6 transaction operations](/img/50/639867a2fcb92082ea262a8a19bb68.png)
[redis]redis6 transaction operations

【21. 合并两个有序链表】

【206. 反转链表】

TC397 Flash

建立自己的网站(12)
随机推荐
ACM. HJ45 名字的漂亮度 ●●
List of outstanding talents: no crystal vibration, one drag, eight burn and upgrade [chapter]
The problem that Jericho can't play the prompt tone in the music mode using the interrupt mode [chapter]
Pytorch's model saving, loading and continuing training
[206. reverse linked list]
第018讲:函数:灵活即强大 | 课后测试题及答案
Jerry's plug-in 4m flash to view the processing method with a size of only 1m on the PC [chapter]
万字长文 | 使用 RBAC 限制对 Kubernetes 资源的访问
快速排序模板 & 注意事项
2022 question bank and simulated examination for work license of main principals of hazardous chemical business units
【206. 反转链表】
HarmonyOS应用开发培训第二次
牛客 52次月赛 C 说谎的机器 (区间赋值操作由O(n^2)转为O(n)的复杂度)
杰理之硬件上 DACL 输出,DAC 输出左右声道的声音【篇】
86- to attend & lt; SQL writing and rewriting training & gt; 's participants add a second-hand case
第020讲:函数:内嵌函数和闭包 | 课后测试题及答案
NBA playoff match chart
软考必备资料大放送,全科目软考资料都给你备好了!
Japanese anime writers and some of their works
第022讲:函数:递归是神马 | 课后测试题及答案