question: protected void onPageScrolled ( int position , float offset , int offsetPixels ) { if ( mDecorChildCount > 0 ) { if ( mOrientation == Orientation . VERTICAL ) { 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 ) ; } } } else { 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 ) ; } } } } if ( mOnPageChangeListener != null ) { mOnPageChangeListener . onPageScrolled ( position , offset , offsetPixels ) ; } if ( mInternalPageChangeListener != null ) { mInternalPageChangeListener . onPageScrolled ( position , offset , offsetPixels ) ; } if ( mPageTransformer != null ) { final int scroll = ( mOrientation == Orientation . VERTICAL ) ? getScrollY ( ) : getScrollX ( ) ; 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 float transformPos = ( float ) ( ( ( mOrientation == Orientation . VERTICAL ) ? child . getTop ( ) : child . getLeft ( ) ) - scroll ) / getClientSize ( ) ; mPageTransformer . transformPage ( child , transformPos ) ; } } mCalledSuper = true ; }
target:  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.