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

loloof64

11/24/2020, 10:39 AM
Hi, how can I actually convert a size in Dp to a size in Px in a composable ? I mean :
Copy code
@Composable
MyComposable(size: Dp) {
// how to get size in px ?
}
Because it seems that
withDensity
is not available in the newest API.
a

André Kindwall

11/24/2020, 10:44 AM
Copy code
@Composable
fun MyComposable(size: Dp) {
    with(DensityAmbient.current) {
        size.toPx()
    }
}
👍 1
l

loloof64

11/24/2020, 10:46 AM
Thank you very much 😃
2 Views