Skip to content

Instantly share code, notes, and snippets.

@arekolek
Created April 16, 2020 18:11
Convert dp to px
interface HasContext {
fun getContext(): Context
val Int.dp
get() = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, this.toFloat(), getContext().resources.displayMetrics).toInt()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment