Is it possible to scale composable content, to fit the available space, while keeping aspect ratio? I would like to scale down my composable, to avoid being cut off, it there is no space. Similar to how
ContentScale.Fit
works for
Image()
.
t
Timo Drick
12/15/2023, 10:43 AM
I do not have a ready solution but i think this could be possible technically.
There is this Modifier.graphicsLayer which you can use for scaling. Maybe you need to encapsulate your composable in a Modifier.wrapContent and then measuer the size Modifier.onSizeChanged and depending on that you can change the scale of the graphicsLayer.
a
Albert Chang
12/15/2023, 11:18 AM
Instead of using
Modifier.onSizeChanged
which needs two layout passes, you can just use a layout modifier: