sudeshim3
10/5/2019 - 11:50 AM

Utility function

//UI Unit conversion.
fun Context.pxToDp(dimension: Int) = dimension / this.resources.displayMetrics.density
fun Context.pxToSp(dimension: Int) = dimension / this.resources.displayMetrics.scaledDensity
fun Context.dpToPx(dimension: Int) = dimension * this.resources.displayMetrics.density
fun Context.spToPx(dimension: Int) = dimension * this.resources.displayMetrics.scaledDensity