getSp and getDp

This commit is contained in:
InsanusMokrassar 2020-11-20 10:23:32 +06:00
parent b6be14ecca
commit d7b46ae0d4
2 changed files with 18 additions and 0 deletions

View File

@ -2,6 +2,11 @@
## 0.4.3
* `Common`:
* Two new extensions for Android:
* `Resources#getSp`
* `Resources#getDp`
## 0.4.2
* `Repos`:

View File

@ -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