I have a scrollable LazyRow that contains numbers, I want for the middle visible number to be automatically selected as shown below:
How could I find the middle visible item in a LazyRow?
code:
@Composable
fun ScrollableAgeSelector(
modifier: Modifier = Modifier
) {
val numbers = (12..100).toList()
LazyRow(
modifier = modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(20.dp)
) {
items(numbers.size) { index ->
val num = numbers[index]
NumberItem(
num = num,
selectedNum = 22
)
}
}
}