Question:
What I want: I want every image to fit as much as it can in the scrollable column. so the image fit the maximum width it can and the height respectively. I can’t figure out how to do this in compose.What I tried: I only succeed to do this by using a fixed size for the image but this isn’t really a solution.
Answer:
If you want theImage
composable to fill the maximum width available you have to use Modifier.fillMaxWidth()
. That is the same with any Composable.And then if you also want the image content to be scaled in such a way that it fills the maximum width first and then proportionally fills the height as well, you have to pass the
ContentScale.FillWidth
value for the contentScale
parameter.Both together in your code
.weight(1f, fill = true)
modifier to the Column.If you have better answer, please add a comment about this, thank you!