Last active
November 2, 2021 18:03
-
-
Save gpeal/c33ed4c61697a9262c5914ccd7e10df0 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
/** | |
* Call this function on a dp value and it will return the equivalent | |
* number of pixels for the current display. | |
* e.g. 8.dp | |
*/ | |
val Number.dp get() = toFloat() * (Resources.getSystem().displayMetrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment