Skip to content

Instantly share code, notes, and snippets.

@weverb2
Created April 18, 2017 14:51
Show Gist options
  • Save weverb2/958ea886c8d18c578e38fe71d37676c1 to your computer and use it in GitHub Desktop.
Save weverb2/958ea886c8d18c578e38fe71d37676c1 to your computer and use it in GitHub Desktop.
Integer Dp to Px extensions
fun Int.pxToDp(): Int = (this / Resources.getSystem().displayMetrics.density).toInt()
fun Int.dpToPx(): Int = (this * Resources.getSystem().displayMetrics.density).toInt()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment