Skip to content

Instantly share code, notes, and snippets.

@lmller
Created February 27, 2017 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmller/5121b7ea70804d2abbd6f2204c885e19 to your computer and use it in GitHub Desktop.
Save lmller/5121b7ea70804d2abbd6f2204c885e19 to your computer and use it in GitHub Desktop.
val Int.dp: Int
get() = resources.dpToPx(this)
fun Resources.dpToPx(dp: Int) = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp.toFloat(), displayMetrics).toInt()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment