protected void onPageScrolled(int position,float offset,int offsetPixels){
  if (mDecorChildCount > 0) {
    if (isOrientationHorizontal()) {
      final int scrollX=getScrollX();
      int paddingLeft=getPaddingLeft();
      int paddingRight=getPaddingRight();
      final int width=getWidth();
      final int childCount=getChildCount();
      for (int i=0; i < childCount; i++) {
        final View child=getChildAt(i);
        final LayoutParams lp=(LayoutParams)child.getLayoutParams();
        if (!lp.isDecor)         continue;
        final int hgrav=lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
        int childLeft=0;
switch (hgrav) {
default :
          childLeft=paddingLeft;
        break;
case Gravity.LEFT:
      childLeft=paddingLeft;
    paddingLeft+=child.getWidth();
  break;
case Gravity.CENTER_HORIZONTAL:
childLeft=Math.max((width - child.getMeasuredWidth()) / 2,paddingLeft);
break;
case Gravity.RIGHT:
childLeft=width - paddingRight - child.getMeasuredWidth();
paddingRight+=child.getMeasuredWidth();
break;
}
childLeft+=scrollX;
final int childOffset=childLeft - child.getLeft();
if (childOffset != 0) {
child.offsetLeftAndRight(childOffset);
}
}
}
 else {
final int scrollY=getScrollY();
int paddingTop=getPaddingTop();
int paddingBottom=getPaddingBottom();
final int height=getHeight();
final int childCount=getChildCount();
for (int i=0; i < childCount; i++) {
final View child=getChildAt(i);
final LayoutParams lp=(LayoutParams)child.getLayoutParams();
if (!lp.isDecor) continue;
final int vgrav=lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;
int childTop=0;
switch (vgrav) {
default :
childTop=paddingTop;
break;
case Gravity.TOP:
childTop=paddingTop;
paddingTop+=child.getHeight();
break;
case Gravity.CENTER_VERTICAL:
childTop=Math.max((height - child.getMeasuredHeight()) / 2,paddingTop);
break;
case Gravity.BOTTOM:
childTop=height - paddingBottom - child.getMeasuredHeight();
paddingBottom+=child.getMeasuredHeight();
break;
}
childTop+=scrollY;
final int childOffset=childTop - child.getTop();
if (childOffset != 0) {
child.offsetTopAndBottom(childOffset);
}
}
}
}
if (mOnPageChangeListener != null) {
mOnPageChangeListener.onPageScrolled(position,offset,offsetPixels);
}
if (mInternalPageChangeListener != null) {
mInternalPageChangeListener.onPageScrolled(position,offset,offsetPixels);
}
if (mPageTransformer != null) {
final boolean horizontal=isOrientationHorizontal();
final int scroll=horizontal ? getScrollX() : getScrollY();
final int childCount=getChildCount();
for (int i=0; i < childCount; i++) {
final View child=getChildAt(i);
final LayoutParams lp=(LayoutParams)child.getLayoutParams();
if (lp.isDecor) continue;
float transformPos;
if (horizontal) {
transformPos=(float)(child.getLeft() - scroll) / getClientWidth();
}
 else {
transformPos=(float)(child.getTop() - scroll) / getClientHeight();
}
mPageTransformer.transformPage(child,transformPos);
}
}
mCalledSuper=true;
}

protected void onPageScrolled ( int position , float offset , int offsetPixels ) { if ( mDecorChildCount > 0 ) { if ( isOrientationHorizontal ( ) ) { final int scrollX = getScrollX ( ) ; int paddingLeft = getPaddingLeft ( ) ; int paddingRight = getPaddingRight ( ) ; final int width = getWidth ( ) ; final int childCount = getChildCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { final View child = getChildAt ( i ) ; final LayoutParams lp = ( LayoutParams ) child . getLayoutParams ( ) ; if ( ! lp . isDecor ) continue ; final int hgrav = lp . gravity & Gravity . HORIZONTAL_GRAVITY_MASK ; int childLeft = 0 ; switch ( hgrav ) { default : childLeft = paddingLeft ; break ; case Gravity . LEFT : childLeft = paddingLeft ; paddingLeft += child . getWidth ( ) ; break ; case Gravity . CENTER_HORIZONTAL : childLeft = Math . max ( ( width - child . getMeasuredWidth ( ) ) / 2 , paddingLeft ) ; break ; case Gravity . RIGHT : childLeft = width - paddingRight - child . getMeasuredWidth ( ) ; paddingRight += child . getMeasuredWidth ( ) ; break ; } childLeft += scrollX ; final int childOffset = childLeft - child . getLeft ( ) ; if ( childOffset != 0 ) { child . offsetLeftAndRight ( childOffset ) ; } } } else { final int scrollY = getScrollY ( ) ; int paddingTop = getPaddingTop ( ) ; int paddingBottom = getPaddingBottom ( ) ; final int height = getHeight ( ) ; final int childCount = getChildCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { final View child = getChildAt ( i ) ; final LayoutParams lp = ( LayoutParams ) child . getLayoutParams ( ) ; if ( ! lp . isDecor ) continue ; final int vgrav = lp . gravity & Gravity . VERTICAL_GRAVITY_MASK ; int childTop = 0 ; switch ( vgrav ) { default : childTop = paddingTop ; break ; case Gravity . TOP : childTop = paddingTop ; paddingTop += child . getHeight ( ) ; break ; case Gravity . CENTER_VERTICAL : childTop = Math . max ( ( height - child . getMeasuredHeight ( ) ) / 2 , paddingTop ) ; break ; case Gravity . BOTTOM : childTop = height - paddingBottom - child . getMeasuredHeight ( ) ; paddingBottom += child . getMeasuredHeight ( ) ; break ; } childTop += scrollY ; final int childOffset = childTop - child . getTop ( ) ; if ( childOffset != 0 ) { child . offsetTopAndBottom ( childOffset ) ; } } } } if ( mOnPageChangeListener != null ) { mOnPageChangeListener . onPageScrolled ( position , offset , offsetPixels ) ; } if ( mInternalPageChangeListener != null ) { mInternalPageChangeListener . onPageScrolled ( position , offset , offsetPixels ) ; } if ( mPageTransformer != null ) { final boolean horizontal = isOrientationHorizontal ( ) ; final int scroll = horizontal ? getScrollX ( ) : getScrollY ( ) ; final int childCount = getChildCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { final View child = getChildAt ( i ) ; final LayoutParams lp = ( LayoutParams ) child . getLayoutParams ( ) ; if ( lp . isDecor ) continue ; float transformPos ; if ( horizontal ) { transformPos = ( float ) ( child . getLeft ( ) - scroll ) / getClientWidth ( ) ; } else { transformPos = ( float ) ( child . getTop ( ) - scroll ) / getClientHeight ( ) ; } mPageTransformer . transformPage ( child , transformPos ) ; } } mCalledSuper = true ; }
this method will be invoked when the current page is scrolled , either as part of a programmatically initiated smooth scroll or a user initiated touch scroll . if you override this method you must call through to the superclass implementation ( e . g . super . onpagescrolled ( position , offset , offsetpixels ) ) before onpagescrolled returns .
