Why don't grid cells in a `LazyVerticalGrid` alway...
# compose
p
Why don't grid cells in a
LazyVerticalGrid
always take the shape of its content? For example:
LazyVerticalGrid(columns = GridCells.Fixed(3)) { ...
full of images of the same size produces this result. I outlined one of the grid cells. Why didn't it take the shape of the image which is its only content? It almost looks as if it can't stretch the image that much for some reason, since it would be considerably bigger that way.
s
How does the item inside the cell look like? Could you just add a simple
Box(Modifier.fillMaxSize().background(Color.Red))
and see if that fills it up? If yes, maybe it's your image that's the issue here.
p
I added the box to the first two items, here is the result. The content is just a plain
Image
with no modifiers apart from
clickable
s
Well then see what parameters image takes in. There must be one which describes how the image is cropped in the available space. The item itself is given the space that it needs as you can see from this change.
c
Image crop may default to Fit. You should try Fill
p
cropped in the available space
But what other than the image itself decides on the available space? This is counterintuitive to me.
try Fill
contentScale = ContentScale.FillWidth
does work indeed, thank you!
s
Yeah what I was saying is that your composable was receiving the correct amount of space, it's just that the image composable takes the available space, and in combination with the contentScale parameter it decides how it will render the image.