ViewPager.OnPageChangeListener监测
@Override
public void onPageScrolled(int position, float positionOffset,
int positionOffsetPixels) {
Log.e("positionOffset", positionOffset+"");
Log.e("positionOffsetPixels", positionOffsetPixels+"");
}
Left to Right
11-16 14:24:11.713: E/positionOffset(16150): 0.018055556
11-16 14:24:11.714: E/positionOffsetPixels(16150): 13
11-16 14:24:11.730: E/positionOffset(16150): 0.04027778
11-16 14:24:11.730: E/positionOffsetPixels(16150): 29
11-16 14:24:11.746: E/positionOffset(16150): 0.06944445
11-16 14:24:11.746: E/positionOffsetPixels(16150): 50
11-16 14:24:11.763: E/positionOffset(16150): 0.10555556
11-16 14:24:11.763: E/positionOffsetPixels(16150): 76
11-16 14:24:11.780: E/positionOffset(16150): 0.14861111
11-16 14:24:11.781: E/positionOffsetPixels(16150): 107
11-16 14:24:11.798: E/positionOffset(16150): 0.19166666
11-16 14:24:11.800: E/positionOffsetPixels(16150): 138
11-16 14:24:11.815: E/positionOffset(16150): 0.25
11-16 14:24:11.815: E/positionOffsetPixels(16150): 180
11-16 14:24:11.832: E/positionOffset(16150): 0.30694443
11-16 14:24:11.833: E/positionOffsetPixels(16150): 220
11-16 14:24:11.851: E/positionOffset(16150): 0.41527778
11-16 14:24:11.851: E/positionOffsetPixels(16150): 299
11-16 14:24:11.854: E/positionOffset(16150): 0.42222223
11-16 14:24:11.854: E/positionOffsetPixels(16150): 304
11-16 14:24:11.867: E/positionOffset(16150): 0.50972223
11-16 14:24:11.867: E/positionOffsetPixels(16150): 367
11-16 14:24:11.885: E/positionOffset(16150): 0.6125
11-16 14:24:11.885: E/positionOffsetPixels(16150): 441
11-16 14:24:11.903: E/positionOffset(16150): 0.69861114
11-16 14:24:11.903: E/positionOffsetPixels(16150): 503
11-16 14:24:11.922: E/positionOffset(16150): 0.7708333
11-16 14:24:11.922: E/positionOffsetPixels(16150): 555
11-16 14:24:11.936: E/positionOffset(16150): 0.81527776
11-16 14:24:11.937: E/positionOffsetPixels(16150): 587
11-16 14:24:11.954: E/positionOffset(16150): 0.85833335
11-16 14:24:11.954: E/positionOffsetPixels(16150): 618
11-16 14:24:11.970: E/positionOffset(16150): 0.89444447
11-16 14:24:11.971: E/positionOffsetPixels(16150): 644
11-16 14:24:11.988: E/positionOffset(16150): 0.9236111
11-16 14:24:11.988: E/positionOffsetPixels(16150): 665
11-16 14:24:12.006: E/positionOffset(16150): 0.9458333
11-16 14:24:12.007: E/positionOffsetPixels(16150): 681
11-16 14:24:12.024: E/positionOffset(16150): 0.9625
11-16 14:24:12.024: E/positionOffsetPixels(16150): 693
11-16 14:24:12.040: E/positionOffset(16150): 0.9736111
11-16 14:24:12.041: E/positionOffsetPixels(16150): 701
11-16 14:24:12.057: E/positionOffset(16150): 0.98194444
11-16 14:24:12.057: E/positionOffsetPixels(16150): 707
11-16 14:24:12.074: E/positionOffset(16150): 0.98888886
11-16 14:24:12.074: E/positionOffsetPixels(16150): 712
11-16 14:24:12.093: E/positionOffset(16150): 0.9930556
11-16 14:24:12.093: E/positionOffsetPixels(16150): 715
11-16 14:24:12.111: E/positionOffset(16150): 0.99583334
11-16 14:24:12.111: E/positionOffsetPixels(16150): 717
11-16 14:24:12.132: E/positionOffset(16150): 0.9986111
11-16 14:24:12.132: E/positionOffsetPixels(16150): 719
11-16 14:24:12.160: E/positionOffset(16150): 0.0
11-16 14:24:12.160: E/positionOffsetPixels(16150): 0
Right to Left
11-16 14:25:05.031: E/positionOffset(16150): 0.9916667
11-16 14:25:05.031: E/positionOffsetPixels(16150): 714
11-16 14:25:05.077: E/positionOffset(16150): 0.9361111
11-16 14:25:05.077: E/positionOffsetPixels(16150): 674
11-16 14:25:05.093: E/positionOffset(16150): 0.8375
11-16 14:25:05.094: E/positionOffsetPixels(16150): 603
11-16 14:25:05.110: E/positionOffset(16150): 0.76666665
11-16 14:25:05.110: E/positionOffsetPixels(16150): 552
11-16 14:25:05.127: E/positionOffset(16150): 0.6666667
11-16 14:25:05.128: E/positionOffsetPixels(16150): 480
11-16 14:25:05.144: E/positionOffset(16150): 0.5472222
11-16 14:25:05.144: E/positionOffsetPixels(16150): 393
11-16 14:25:05.168: E/positionOffset(16150): 0.16527778
11-16 14:25:05.168: E/positionOffsetPixels(16150): 119
11-16 14:25:05.171: E/positionOffset(16150): 0.15833333
11-16 14:25:05.171: E/positionOffsetPixels(16150): 114
11-16 14:25:05.181: E/positionOffset(16150): 0.097222224
11-16 14:25:05.181: E/positionOffsetPixels(16150): 70
11-16 14:25:05.197: E/positionOffset(16150): 0.03888889
11-16 14:25:05.198: E/positionOffsetPixels(16150): 28
11-16 14:25:05.214: E/positionOffset(16150): 0.0125
11-16 14:25:05.214: E/positionOffsetPixels(16150): 9
11-16 14:25:05.233: E/positionOffset(16150): 0.0013888889
11-16 14:25:05.234: E/positionOffsetPixels(16150): 1
11-16 14:25:05.248: E/positionOffset(16150): 0.0
11-16 14:25:05.248: E/positionOffsetPixels(16150): 0
顺便说一下:
@Override
public void onPageScrollStateChanged(int position) {
}
其中最好不要写代码,因为打印结果如下:
11-16 17:08:27.034: E/onPageSelected(7442): 1
11-16 17:08:27.344: E/SenderFragment(7442): on Resume
11-16 17:08:29.244: E/onPageScrollStateChanged(7442): 1
11-16 17:08:29.369: E/onPageScrollStateChanged(7442): 2
11-16 17:08:29.370: E/onPageSelected(7442): 2
11-16 17:08:30.026: E/onPageScrollStateChanged(7442): 0
11-16 17:08:31.446: E/onPageScrollStateChanged(7442): 1
11-16 17:08:31.496: E/onPageScrollStateChanged(7442): 2
11-16 17:08:31.497: E/onPageSelected(7442): 1
11-16 17:08:32.005: E/onPageScrollStateChanged(7442): 0
11-16 17:08:32.745: E/onPageScrollStateChanged(7442): 1
11-16 17:08:32.839: E/onPageScrollStateChanged(7442): 2
11-16 17:08:32.840: E/onPageSelected(7442): 2
11-16 17:08:33.495: E/onPageScrollStateChanged(7442): 0
11-16 17:08:33.691: E/onPageScrollStateChanged(7442): 1
11-16 17:08:33.802: E/onPageScrollStateChanged(7442): 2
11-16 17:08:33.803: E/onPageSelected(7442): 1
11-16 17:08:34.445: E/onPageScrollStateChanged(7442): 0
11-16 17:08:36.591: E/onPageScrollStateChanged(7442): 1
11-16 17:08:36.723: E/onPageScrollStateChanged(7442): 2
11-16 17:08:37.356: E/onPageScrollStateChanged(7442): 0
11-16 17:08:37.417: E/onPageScrollStateChanged(7442): 1
11-16 17:08:37.540: E/onPageScrollStateChanged(7442): 2
11-16 17:08:37.540: E/onPageSelected(7442): 2
11-16 17:08:38.171: E/onPageScrollStateChanged(7442): 0
11-16 17:08:41.443: E/onPageScrollStateChanged(7442): 1
11-16 17:08:41.560: E/onPageScrollStateChanged(7442): 2
11-16 17:08:41.561: E/onPageSelected(7442): 1
11-16 17:08:42.204: E/onPageScrollStateChanged(7442): 0
11-16 17:08:44.500: E/onPageScrollStateChanged(7442): 1
11-16 17:08:44.587: E/onPageScrollStateChanged(7442): 2
11-16 17:08:44.588: E/onPageSelected(7442): 0
11-16 17:08:45.111: E/onPageScrollStateChanged(7442): 0
11-16 17:08:49.470: E/SenderFragment(7442): on Stop