eygraber
03/03/2023, 4:53 AMLazyColumn
items when applying a verticalArrangement
? More details in 🧵LazyColumn
that has 1 item at the top that manages the spacing between it and the next item. I want all items after that to be spaced by 16.dp
.
I tried creating a custom Arrangement.Vertical
that in arrange
manually handles the 1st item, and delegates to an Arrangement.spacedBy(16.dp)
for the other items.
The problem is that LazyColumn
only calls Arrangement.arrange
when there is "spare space" (i.e. when the items don't extend past its viewport). In order to get the proper spacing, I have to also delegate spacing
to the Arrangement.spacedBy(16.dp)
, but that applies to my first as well.LazyColumn
inside a vertically scrolling Column
and put the first item in that Column
but that comes with its own challenges, specifically the issue where a vertically scrollable component has an infinite maximum height. The exception even calls out this case explicitly:
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
LazyColumn
where I want my first item to have a specific padding that is different from the rest of the items.
Any chance that item
could get a parameter specifying whether it should ignore contentPadding
and verticalArrangement
?shikasd
03/04/2023, 2:10 PMitem {
// First item with specific padding
Spacer(Modifier.size(firstItemPadding)
}
items {
// The rest of the list
}
You can also try and arrange items with Spacer/padding modifier without the arrangementeygraber
03/05/2023, 1:35 AMshikasd
03/05/2023, 2:40 AMeygraber
03/05/2023, 3:35 AMshikasd
03/06/2023, 12:12 PM