Skip to content

Instantly share code, notes, and snippets.

@CodingDoug
Created February 22, 2016 18:07
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 CodingDoug/489045d5a92be732dec9 to your computer and use it in GitHub Desktop.
Save CodingDoug/489045d5a92be732dec9 to your computer and use it in GitHub Desktop.
import android.view.View
fun View.dp_f(dp: Float): Float {
return TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, dp, context.resources.displayMetrics)
}
fun View.dp_i(dp: Float): Int {
return dp_f(dp).toInt()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment