1

I'm starting using Jetpack compose and i'm facing some issues with Lazy Column.

The problem is that i want to make a list that contains another list inside every root item (such as a card that containt another list inside).

Unfortunately, when i run the following code (below the snippet that resume what i'm trying to do).

I catch the exception:

java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed. One of the common reasons is nesting layouts like LazyColumn and Column(Modifier.verticalScroll()). 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 LazyColumn 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.

Code:

LazyColumn(modifier = Modifier.wrapContentHeight()) {
    items(list.value) { 
        item -> LazyColumn(modifier = Modifier.wrapContentHeight()) {
            //some Text
        }
    }
}

I don't need the nested Lazy Column to be scrollable, so i'm wondering if for this purpose there is another element to use instead of LazyColumn, or i'm making some other mistake.

I've also tried to put in item{} block other layout elements, as suggested by the Exception, but with the same result.

4
  • 3
    You must specify the height of the second LazyColumn Commented Mar 6, 2022 at 11:24
  • Thank you Nesyou, I've specified the height of the second LazyColumn has a multiple of the size list of item that I want to display. It works properly Commented Mar 6, 2022 at 12:18
  • Can't you use for loop instead of inner lazy column? Commented Mar 6, 2022 at 17:37
  • 4
    @Sguit how did you specified the height of the second LazyColumn? Commented Apr 6, 2022 at 6:23

2 Answers 2

0

No, unfortunately, nesting scrollable composables in the same direction is not allowed.

Sign up to request clarification or add additional context in comments.

Comments

0

It's not supported in jetpack compose, but I think it should be supported because many use cases need that. e.g e-commerce applications,food delivery (like DoorDash)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.