Reputation: 26
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)
)
}
}
}
Upvotes: 0
Views: 308