PeterZ
06/27/2023, 9:32 PManchorType
, autoCentering
and flingBehavior
. I thought the snapping behavior (described in anchorType
docs) would do the same as flingBehavior
(ScalingLazyColumnDefaults.snapFlingBehavior
).
What is the difference between those two and why don't they both work the same?
Also does autoCentering
work only for centering of the first and the last element in a ScalingLazyColumn?
ThanksJohn Nichol
06/28/2023, 2:34 PMJohn Nichol
06/28/2023, 2:36 PMJohn Nichol
06/28/2023, 2:36 PMPeterZ
06/28/2023, 2:36 PMJohn Nichol
06/28/2023, 2:37 PMPeterZ
06/28/2023, 2:38 PMflingBehavior
(ScalingLazyColumnDefaults.snapFlingBehavior
)?John Nichol
06/28/2023, 2:39 PM@Sampled
@Composable
fun SimpleScalingLazyColumnWithSnap() {
val state = rememberScalingLazyListState()
ScalingLazyColumn(
modifier = Modifier.fillMaxWidth(),
state = state,
flingBehavior = ScalingLazyColumnDefaults.snapFlingBehavior(state = state)
) {
item {
ListHeader {
Text(text = "List Header")
}
}
items(20) {
Chip(
onClick = { },
label = { Text("List item $it") },
colors = ChipDefaults.secondaryChipColors()
)
}
}
}
PeterZ
06/28/2023, 2:40 PMJohn Nichol
06/28/2023, 2:40 PM