Deji Akande
07/14/2023, 6:54 PMHorizontally scrollable component was measured with an infinity maximum width constraints, which is disallowed. One of the common reasons is nesting layouts like LazyRow and Row(Modifier.horizontalScroll()). If you want to add a header before the list of items please add a header as a separate item() before the main items() inside the LazyRow scope. There are could be other reasons for this to happen: your ComposeView was added into a LinearLayout with some weight, you applied Modifier.wrapContentSize(unbounded = true) or wrote a custom layout. Please try to remove the source of infinite constraints in the hierarchy above the scrolling container.
I'm surprised this is an invalid combination. 🤔
My understanding is there are two passes to weighted children of linearLayouts, the first one passes 0 and then the second passes the appropriate width by sharing the available space with the weighted children
However, on debugging (using BoxWithConstraints) it seems that on the initial pass the maxWidth passed to the ComposeView is Infinity. Which causes the error above.
Is there any recommended approach for having Scrollable content embedded in linearLayouts with width?
I have a hack which is using
Modifier.widthIn(0.dp, 0.dp)
Which works because it is a more restrictive constraint than the (0, Infinity) constraint passed on the first measure phase of the linearlayout
But seems weird that this is not supported by default.romainguy
07/14/2023, 6:57 PMthe first one passes 0
romainguy
07/14/2023, 6:57 PMUNSPECIFIED
romainguy
07/14/2023, 6:58 PMDeji Akande
07/14/2023, 7:24 PMromainguy
07/14/2023, 7:29 PMUNSPECIFIED
never meant 0
. Note also that Compose was designed to not have double measurement passes, so it might be related to thatromainguy
07/14/2023, 7:32 PMLazyRow
in an infinite container would technically require to measure all possible items to figure out how big it wants to be (which of course goes against the concept of LazyRow
in the first place)romainguy
07/14/2023, 7:34 PMromainguy
07/14/2023, 7:34 PMLinearLayout
romainguy
07/14/2023, 7:35 PMDeji Akande
07/14/2023, 7:42 PMThe problem — I think, you’d have to ask the engineers on my team — is that aYeah. I wouldn’t expect this too. I’d more expect that it doesn’t compose any item at all when it receives infinite constraints.in an infinite container would technically require to measure all possible items to figure out how big it wants to be (which of course goes against the concept ofLazyRow
in the first place)LazyRow
Deji Akande
07/14/2023, 7:43 PMDeji Akande
07/17/2023, 12:14 PMTurn off baseline alignement on theThanks @romainguy . This WorkedLinearLayout