Is there a composable/modifier that would scale a ...
# compose
z
Is there a composable/modifier that would scale a composable to fit (or preferably fill) in the available space? (something like FittedBox from Flutter)
a
Box(propagateMinConstraints = true) {}
đź‘Ť 1
t
Modifier.weight(1f) could also work
a
We are talking about forcing the children of a layout to fill max size from the parent size (i.e. without applying modifiers to children). If you can use modifiers on children, why don’t you use
Modifier.fillMaxSize()
?
z
propagateMinConstraints
and
fillMaxSize
doesn’t really work for me In my case, I would like to scale the view down to fit the container. So let’s assume the composable is just a
Column()
with an image and some text below it, depending on the text value and font size (which can vary a lot with accessibility settings) this view can grow significantly. In case it get’s bigger than the container, I would like it to automatically scale down (adjusting just the text size is not ok as I would like to keep proper ratio between an image size and the text size). Anyway I think I’m able to achieve it with
Copy code
.aspectRatio(ratio)
.wrapContentHeight(unbounded = true)
.scale(scaleValue)
where proper
scaleValue
I can calculate based on the container size and my view size