In a `LazyVerticalGrid`, is there a way to make su...
# compose
s
In a
LazyVerticalGrid
, is there a way to make sure that all items in the same horizontal group are measured with the same height? So that when looking at one of the rows there are no discrepancies on their height between the items? Doing a
fillMaxHeight
does not work since their constraints give them infinite height, and I do not see there being any custom modifier for that scope like
BoxScope
gets with
matchParentSize()
And I see that the staggered version exists which is an option, but I am still interested in seeing if I can make it work with the non-staggered option instead.
p
maybe this will help use
aspectRatio(1f)
on item modifier
Copy code
LazyVerticalGrid(
	columns = GridCells.Fixed(4),
){

	item{

		  LibraryPlaylistGird(
                   modifier = Modifier
                   .aspectRatio(1f)
		  )

	}

}


LibraryPlaylistGird(
    modifier: Modifier = Modifier,
){
	Column(
        	modifier = modifier,
    	) {

	}
Copy code
}
every item will be same size
🙌 1
s
I don't need the aspect ratio to be 1:1 unfortunately, in fact it's something I actively would want to avoid.
p
if items are of different size then u can use staggered as you have said earlier. if that is not the case then i don't know how to do it . if you use
size
modifier that would be bad for different screen size and
filMaxSize
is not an option. you can calculate width of the screen and then assign size to them item but that is what
aspectRatio
does. sorry maybe I don't have knowledge to help :)
gratitude thank you 1
s
Thanks a lot for trying to help regardless, it may be that there simply isn't a good solution for this and staggered grid is what I should be going for anyway. Quite a different experience, but it at least looks okay. I could also make a custom grid which is not lazy, and therefore can layout its children one by one using intrinsic min heights to measure the items with the same height. Provided this would be a much more involved solution, prone to my own mistakes, and not even lazy 😅
c
@Stylianos Gakis I guess you never figured this out?
s
I don't remember at all 😂
c
😅