To add androidx viewpager2 bindings, import corbind-viewpager2
module:
dependencies {
implementation("ru.ldralighieri.corbind:corbind-viewpager2:1.11.0")
}
Component | Extension | Description |
---|---|---|
ViewPager2 | pageScrollEvents |
Called when the current page is scrolled, either as part of a programmatically initiated smooth scroll or a user initiated touch scroll. |
pageScrollStateChanges |
Called when the scroll state changes. | |
pageSelections |
Called when a new page becomes selected. |
vpSlides.pageSelections() // Flow<Int>
.onEach { tvMessage = "Page #$it selected" }
.flowWithLifecycle(lifecycle)
.launchIn(lifecycleScope) // lifecycle-runtime-ktx
More examples in source code