0

I want to have a vertical lazy list of items where each item take parent width when horizontal scroll isn't available, otherwise max IntrinsicWidth among all children.

I know roughly how to do this with SubcomposeLayout. But it requires to implement by hand laziness logic which is hard to do without occasionally harming performance. And also Subcompose layout will compose each element twice which is also bad.

So question is how to implement such logic without painfully creating LazyList from the ground up?

Here is minimal code that i've tried. I use fillParentMaxWidth modifier but it doesn't work. fillMaxWidth also dindn't work because when i use horizontalScroll modifier on parent it passes unbounded constraints to its children and fillMaxWidth is just being ignored.

width(IntrinsicSize.Max) modifier on LazyColumn also didn't work because "Intrinsic measurements are not currently supported by SubcomposeLayout"

LazyColumn(
    modifier = Modifier
        .fillMaxSize()
        .horizontalScroll(rememberScrollState()),
) {
    repeat(20) {
        item {
            Text(
                text = "$it ................................",
                modifier = Modifier
                    .fillParentMaxWidth()
                    .background(Color.Gray)
            )
        }
    }
}

Code output

1 Answer 1

0

I recomemnd using a Row with horizontal scroll in each item.

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

2 Comments

Welcome to StackOverflow. Please, edit and try for How to Answer, describe the effect of what you propose and explain why it helps to solve the problem. Consider taking the tour.
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

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.