@@ -166,6 +166,7 @@ public TabPagerIndicator(Context context, AttributeSet attrs, int defStyle) {
166
166
}
167
167
}
168
168
169
+
169
170
public void setIndicatorMode (IndicatorMode indicatorMode ) {
170
171
this .setIndicatorMode (indicatorMode , false );
171
172
}
@@ -252,7 +253,6 @@ private void obtainAttrs(Context context, AttributeSet attrs) {
252
253
253
254
public void setViewPager (ViewPager pager ) {
254
255
this .pager = pager ;
255
-
256
256
if (pager .getAdapter () == null ) {
257
257
throw new IllegalStateException ("ViewPager does not have adapter instance." );
258
258
}
@@ -390,6 +390,8 @@ private void scrollToChild(int position, int offset) {
390
390
if (tabCount == 0 ) {
391
391
return ;
392
392
}
393
+ int newScrollInstance ;
394
+
393
395
int newScrollX ;
394
396
View child = tabsContainer .getChildAt (position );
395
397
int left = child .getLeft ();
@@ -473,6 +475,7 @@ private class PageListener implements OnPageChangeListener {
473
475
474
476
@ Override
475
477
public void onPageScrolled (int position , float positionOffset , int positionOffsetPixels ) {
478
+ Log .d ("onPageScrolled--" ,"position--" +position +"-----positionOffset-----" +positionOffset );
476
479
currentPosition = position -startOffet ;
477
480
currentPositionOffset = positionOffset ;
478
481
if (currentPosition >=0 ){
@@ -486,6 +489,17 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
486
489
Log .i (TAG , "onPageScrolled:width=" + width );
487
490
scrollToChild (currentPosition , (int ) (positionOffset * width ));
488
491
//调用这个方法重新绘制
492
+ }else {
493
+ if (pager .getCurrentItem ()<startOffet ){
494
+ View child = tabsContainer .getChildAt (0 );
495
+ int width = child .getWidth ();
496
+
497
+ if (!isSame ) {
498
+ width += horizontalPadding * 2 ;
499
+ }
500
+ Log .i (TAG , "onPageScrolled:width=" + width );
501
+ scrollToChild (0 , (int ) (positionOffset * width ));
502
+ }
489
503
}
490
504
invalidate ();
491
505
if (delegatePageListener != null ) {
@@ -509,8 +523,9 @@ public void onPageSelected(int position) {
509
523
510
524
lastSelectPosition =selectCurPotition ;
511
525
selectCurPotition =position -startOffet ;
512
- Log .i ("xujun" , "lastSelectPosition:=" + lastSelectPosition );
513
- Log .i ("xujun" , "selectCurPotition:=" +selectCurPotition );
526
+ Log .i ("xujunonPageSelected" , "position:=" + position );
527
+ Log .i ("xujunonPageSelected" , "lastSelectPosition:=" + lastSelectPosition );
528
+ Log .i ("xujunonPageSelected" , "selectCurPotition:=" +selectCurPotition );
514
529
515
530
if (selectCurPotition >=0 ){
516
531
View currentTab = tabsContainer .getChildAt (selectCurPotition );
0 commit comments