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

Ashu

08/21/2021, 11:43 AM
The
onSizeChanged
modifier provides size values in
IntSize
, and the
onSizeChanged
lambda is not a composable function either. How can I get size in
Dp
inside
onSizeChanged
modifier lambda.??
d

Dominaezzz

08/21/2021, 12:09 PM
I'm guessing you're having trouble accessing
LocalDensity
then?
a

Ashu

08/21/2021, 3:28 PM
Yep, since that requires composable scope
d

Dominaezzz

08/21/2021, 3:37 PM
Read it in the composable function the consume in the lamdba. There are many ways to make this work.
a

Ashu

08/21/2021, 7:00 PM
Well yeah, I am making it work by keeping the 1dp to px mapping in the outside composable and using that to convert in
onSizeChanged
but I was hoping if there were a better way to do this.
32 Views