i want to scroll the view pager horizontally on button click in jetpack compose.Anyone have any idea about this ? Here i am using Accompanist library.
You need to use pager state like this:
val state = rememberPagerState()
val scope = rememberCoroutineScope()
Button(onClick = {
scope.launch {
state.scrollToPage(state.currentPage + 1)
// or
state.scrollBy(100f)
}
}) {
}
VerticalPager(
pagesCount,
state = state
) { page ->
}