Hi, I have a LazyVerticalGrid of images, and I wan...
# compose
t
Hi, I have a LazyVerticalGrid of images, and I want to know the size of the cells so I know what size images to fetch. How can I get the size of an individual cell? Because the size is dynamically determined by the number of columns, spacing, and contentPadding, I don't know the size ahead of time.
c
Do you know the number of columns?
t
The number of columns can change but I know the number of columns
c
If you have the device width and the number of columns, is that good enough to get you close to the size of your cells?
t
Yeah but I want the exact size, and the width of the LazyVerticalGrid could be less than the device width.
z
You can use Modifier extension function onGloballyPositioned on LazyVerticalGrid's Modifier and you have LayoutCoordinate in its lamda you can get LayoutCoordinate.IntSize the size of your verticalGrid and also you can get LayoutCoordinate.parentLayoutCoordinate, hope it may help you.
Then you can divide width of grid will columns