private void updateMatrix ( int position , float offset ) { if ( mDrawable != null && mScale > 0.0f ) { if ( mPageCount == - 1 && mAdapter != null ) { // cache page count and translation values mPageCount = mAdapter . getCount ( ) ; if ( mPageCount > 1 ) { mPageX = ( mDrawableWidth * mScale - mViewWidth ) / ( mPageCount - 1 ) ; mPageY = ( mDrawableHeight * mScale - mViewHeight ) / ( mPageCount - 1 ) ; } } mMatrix . setTranslate ( - mPageX * position - mPageX * offset , - mPageY * position - mPageY * offset ) ; mMatrix . preScale ( mScale , mScale ) ; mView . setScaleType ( MATRIX ) ; mView . setImageMatrix ( mMatrix ) ; } }
Scale the image and translate it according to the pager position and offset .