当前位置:网站首页>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()
}
边栏推荐
- 70 root cause analysis Oracle database sudden performance problems, who will take the blame
- RealNetworks vs. 微软:早期流媒体行业之争
- 分享insert into select遇到的死锁问题(项目实战)
- 杰理之在music模式下提示音使用打断模式无法播放的问题【篇】
- [142. circular linked list II]
- Evaluation index and code realization (ndcg)
- 300. 最长递增子序列 ●●
- [206. reverse linked list]
- kali2021安装RTL8188GU无线网卡[TL-WN726N]驱动
- [redis] cluster and common errors
猜你喜欢
随机推荐
Redis learning notes
【876. 链表的中间结点】
Jerry's music mode obtains the directory of playing files [chapter]
94-SQL优化案例一则(用到的写法经常是被嫌弃的)
数据库总结:mysql在开发过程中常见的问题及优化
基于AI驱动大分子药物发现,「华深智药」获近5亿元A轮融资
Objective-C byte size occupied by different data types
las 点云创建网格
Apple corefoundation source code
Learning websites that programmers must see
Arcgis中las点云数据抽稀
ACM. HJ45 名字的漂亮度 ●●
[redis]redis的持久化操作
[Jianzhi offer] interview question 44 A digit in a sequence of numbers
[20. valid brackets]
73- find the SQL example during the business peak period (report development class)
Differences between watch, computed and methods
RealNetworks vs. 微软:早期流媒体行业之争
Jerry's dynamic switching EQ document [chapter]
浅析 Open API 设计规范

![[redis]Redis6的主从复制](/img/47/3be33a0d7435bd75cdd6e7b4ea51d4.png)



![[redis] three new data types](/img/ce/8a048bd36b21bfa562143dd2e47131.png)
![[redis]Redis6的事务操作](/img/50/639867a2fcb92082ea262a8a19bb68.png)


![[206. reverse linked list]](/img/c8/d83655395379a512c8b67a82dc4cae.png)