See next answer in so, but here simply I can determine that has changed page. How can i determine when a user is scrolling ViewPager
?
Asked
Active
Viewed 705 times
0

Morozov
- 4,968
- 6
- 39
- 70
-
1The answer below the one you posted shows you how - `onPageScrollStateChanged` – Ivan Wooll Sep 02 '19 at 14:22
1 Answers
1
You can attach an OnPageChangeListener
to your ViewPager
and override its methods. When the pager is scrolled, the method onPageScrolled
is called while it's scrolled, so you can use that.
view_pager.addOnPageChangeListener(object : OnPageChangeListener {
...
override fun onPageScrolled(
position: Int,
positionOffset: Float,
positionOffsetPixels: Int)
{
Log.d("Debugging", "Pager is now scrolling: $positionOffset")
}
...
})
You can also use the method onPageScrollStateChanged
from OnPageChangeListener
to find out when the scrolling state is changing. The state
param of that method can be SCROLL_STATE_IDLE
, SCROLL_STATE_DRAGGING
, SCROLL_STATE_SETTLING
.

Marius Andrei Rosu
- 70
- 9