Last active
March 20, 2023 04:09
-
-
Save akshaykalola28/4bedc911aa5f4082907f3212a5f56e81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.res.Resources | |
// Convert px to dp | |
val Int.dp: Int | |
get() = (this / Resources.getSystem().displayMetrics.density).toInt() | |
//Convert dp to px | |
val Int.px: Int | |
get() = (this * Resources.getSystem().displayMetrics.density).toInt() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment