https://kotlinlang.org logo
#compose
Title
# compose
m

mgrazianodecastro

03/28/2023, 7:36 PM
Easy way to convert from Dp to pixel? I'm trying to debug some screen
Copy code
with(LocalDensity.current) {
// code here, Dp interface will have the extension .toPx()
}
m

maiatoday

03/28/2023, 7:46 PM
there is an extension already on Android but for desktop I have these
Copy code
@Composable
fun Dp.toPx() = with(LocalDensity.current) { this@toPx.toPx() }

@Composable
fun Int.toDp() = with(LocalDensity.current) { this@toDp.toDp() }
7 Views