M-Miyazako
1/16/2020 - 8:23 AM

pxとdpの相互変換

pxとdpの相互変換

val Int.dpToPx: Int get() = (this * Resources.getSystem().displayMetrics.density + 0.5f).toInt()

val Int.pxToDp: Int get() = (this / Resources.getSystem().displayMetrics.density + 0.5f).toInt()