Pablo
11/11/2024, 12:25 PMlazycolumn
inside a lazycolumn
? I'm getting this error:
> IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed.
I know that as doc says (https://developer.android.com/develop/ui/compose/lists#avoid-nesting-scrollable), we must avoid nesting components scrollable in the same direction.
But my app is an special app, like an "app constructor" in which the user can construct an app using different types of items, for example: texts, images, vertical scroll containers (lazycolumns
), horizontal scroll containers (lazyrows
), etc and for example, the user is free to put a vertical scroll, with some text and an horizontall scroll, and that horizontal scroll can have a verticall scroll inside. I need to know how to achieve thisStylianos Gakis
11/11/2024, 12:27 PMPablo
11/11/2024, 12:29 PMavoid nesting components scrollable in the same direction
but my app is an "app constructor" in which the user can construct an app using texts, images, vertical scroll containers (lazycolumns), etc and he can put a vertical scroll, with some text and an horizontall scroll, with a verticall scroll inside for example. I need to know how to achieve this (editadoSergey Y.
11/11/2024, 12:46 PMPablo
11/11/2024, 12:48 PMPablo
11/11/2024, 12:49 PMSergey Y.
11/11/2024, 12:51 PMPablo
11/11/2024, 12:52 PMSergey Y.
11/11/2024, 12:52 PMI need to allow itSo how do you expect it to work if you try to include a lazy list within another lazy list? What kind of UX are you aiming for with that setup?
Pablo
11/11/2024, 12:55 PMSergey Y.
11/11/2024, 12:56 PMPablo
11/11/2024, 12:56 PMSergey Y.
11/11/2024, 12:58 PMPablo
11/11/2024, 12:58 PMPablo
11/11/2024, 12:59 PMPablo
11/11/2024, 12:59 PMPablo
11/11/2024, 12:59 PMPablo
11/11/2024, 12:59 PMSergey Y.
11/11/2024, 1:00 PMPablo
11/11/2024, 1:00 PMSergey Y.
11/11/2024, 1:01 PMthis was perfectly possible under android view systemNo, it wasn’t. RecyclerView doesn’t throw an error when you nest one inside another. Instead, the embedded RecyclerView simply stops recycling items and behaves like a regular, non-lazy layout, keeping all its items in memory. That’s how it was designed. It doesn’t crash, but it’s no longer lazy either.
Pablo
11/11/2024, 1:01 PMPablo
11/11/2024, 1:01 PMSergey Y.
11/11/2024, 1:02 PMSergey Y.
11/11/2024, 1:03 PM<https://developer.android.com/develop/ui/compose/touch-input/pointer-input/scroll#nested-scrolling>
Sergey Y.
11/11/2024, 1:04 PMPablo
11/11/2024, 1:04 PMPablo
11/11/2024, 1:04 PMPablo
11/11/2024, 1:05 PMSergey Y.
11/11/2024, 1:05 PMPablo
11/11/2024, 1:09 PMPablo
11/11/2024, 1:09 PMSergey Y.
11/11/2024, 1:10 PMI will lose the benefits of lazy loadingIf you’re already nesting lazy lists that scroll in the same direction, you’re effectively losing the lazy behavior, because that’s not how it’s designed to work. This isn’t how it worked with RecyclerView either.
Pablo
11/11/2024, 1:11 PMPablo
11/11/2024, 1:11 PMPablo
11/11/2024, 1:11 PMPablo
11/11/2024, 1:11 PMSergey Y.
11/11/2024, 1:12 PMPablo
11/11/2024, 1:14 PMPablo
11/11/2024, 1:14 PMPablo
11/11/2024, 1:15 PMPablo
11/11/2024, 1:15 PMSergey Y.
11/11/2024, 1:18 PMPablo
11/11/2024, 1:22 PMPablo
11/11/2024, 1:22 PMSergey Y.
11/11/2024, 1:23 PMPablo
11/11/2024, 1:24 PMPablo
11/11/2024, 1:25 PMPablo
11/11/2024, 1:26 PMPablo
11/11/2024, 2:46 PM.heightIn(max = Short.MAX_VALUE.toInt().dp)
Pablo
11/11/2024, 2:48 PMStylianos Gakis
11/11/2024, 10:51 PMColumn(
modifier = Modifier.verticalScroll(scrollState)
) {
LazyColumn(
modifier = Modifier.height(200.dp)
) {
// ...
}
}
But reading what you want to achieve, this does not look to be what you actually want to do here 😄 Did you test this and does it actually behave how you wish it to, besides it just not crashing?Pablo
11/12/2024, 7:04 AMPablo
11/12/2024, 7:05 AMPablo
11/12/2024, 7:05 AMSergey Y.
11/12/2024, 7:26 AMPablo
11/12/2024, 7:28 AMSergey Y.
11/12/2024, 7:30 AMSergey Y.
11/12/2024, 7:34 AMPablo
11/12/2024, 7:34 AMSergey Y.
11/12/2024, 7:36 AMSergey Y.
11/12/2024, 7:38 AM