Android ViewPager sliding Event Description
When I was working on a project today, I made a small research on viewPager page slide events:
First, ViewPager uses OnPageChangeListener to process sliding events.
OnPageChangeListener: (onPageScrollStateChanged, onPageScrolled, onPageSelected)
OnPageScrollStateChanged (int arg0), which is called when the status changes, where arg0
There are three States (0, 1, 2 ). Arg0 = 1 of the hour is sliding, arg0 = 2 of the hour of the implied sliding is completed, arg0 = 0 of the hour of the implied nothing.
When the page starts to slide, the order of the three States is (1, 2, 0), as shown below:
Code block when viewPager status changes:
Print result:
OnPageScrolled (int arg0, float arg1, int arg2), this method is called when the page is sliding. This method is always obtained until the sliding is stopped.
Call. The meanings of the three parameters are as follows:
Arg0: Current page, and the page you click to slide
Arg1: percentage of current page offset
Arg2: The pixel position of the current page offset
(See the official website: http://docs.eoeandroid.com/reference/android/support/v4/view/ViewPager.OnPageChangeListener.html#onPageScrolled (int, float, int ))
The demo is as follows:
Code for Page scrolling:
Log printing:
OnPageSelected (int arg0): This method is called after the page is redirected, and arg0 is the Position (Position number) of the selected page ).