https://kotlinlang.org logo
#compose-android
Title
# compose-android
m

Mahmoo

10/12/2023, 6:24 PM
java.lang.IllegalArgumentException: LazyHorizontalGrid's height should be bound by parent. Getting this error for quite some time.. The thing is I have a colum which I want to make vertically scrollable. It contains 1 LazyHorizontalGrid with span=4, and 2 more lazy row beneath it.. Problem is that whenever I am adding vertical scroll modifier it throws aboce exception and the app crashes.
I tried by making the outer column to be lazy column but sill facing the same issue
v

vide

10/12/2023, 8:39 PM
The exception is trying to tell that you can't nest infinitely expanding layouts. You need to define a maximum height for the inner LazyGrid.
If you wouldn't do this, the grid would just fill up all space in the scrollable layout because it will allow infinite height for the content.
So give a Modifier.heightIn(max = [something].dp)
m

Mahmoo

10/13/2023, 4:30 AM
The thing is that the height of the items of LazyGrid is unknown to me how do I find out its items heights before hand?
v

vide

10/13/2023, 5:28 AM
How high do you want the grid to be? Screen height? A fixed amount of rows dependant on the item heights?
m

Mahmoo

10/13/2023, 11:26 AM
the height of the items are known to me... But I want 4 rows and based on this I need the size of parent
17 Views