Home > other >  Snap to an index Lazyrow
Snap to an index Lazyrow

Time:04-18

So i am making a calendar with the help of a lazyRow. I now have the problem that i want the row to snap to the index after a certain scrollammount so it shouldnt be possible to be stuck inbetween indexes. is there a way to do that?

    LazyRow(state = calendarViewModel.listState, modifier = Modifier.fillMaxWidth()) {
        calendarYears.forEach {
            items(it.months.count()) { index ->
                calendarViewModel.onEvent(CalendarEvent.ClickedMenuItem(index))
                CalendarRowItem(
                    modifier = Modifier.fillParentMaxWidth(),
                    calendarSize = it.months[index].ammountOfDays,
                    initWeekday = it.months[index].startDayOfMonth.ordinal,
                    textColor = MaterialTheme.colors.secondaryVariant,
                    clickedColor = MaterialTheme.colors.primary,
                    textStyle = MaterialTheme.typography.body1
                )
            }
        }

    }

CodePudding user response:

You can use the HorizontalPager from enter image description here

  • Related