mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-22 16:47:15 +00:00
getSp and getDp
This commit is contained in:
parent
b6be14ecca
commit
d7b46ae0d4
@ -2,6 +2,11 @@
|
||||
|
||||
## 0.4.3
|
||||
|
||||
* `Common`:
|
||||
* Two new extensions for Android:
|
||||
* `Resources#getSp`
|
||||
* `Resources#getDp`
|
||||
|
||||
## 0.4.2
|
||||
|
||||
* `Repos`:
|
||||
|
@ -0,0 +1,13 @@
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
package dev.inmo.micro_utils.common
|
||||
|
||||
import android.content.res.Resources
|
||||
|
||||
inline fun Resources.getSp(
|
||||
resId: Int
|
||||
) = getDimension(resId) / displayMetrics.scaledDensity
|
||||
|
||||
inline fun Resources.getDp(
|
||||
resId: Int
|
||||
) = getDimension(resId) * displayMetrics.density
|
Loading…
Reference in New Issue
Block a user