Code example for ViewPager.OnPageChangeListener

Methods: getPaddingLeft, getWidth

0
		mCurItem = position;
	} 
	 
	void updatePositions(int positionOffsetPixels){
		int textWidth = mCurrent.getWidth() - mCurrent.getPaddingLeft() - mCurrent.getPaddingRight();
		int maxOffset = this.getWidth() / 2 - textWidth / 2 - mArrowPadding;
		if(positionOffsetPixels > 0){
			maxOffset -= this.getPaddingLeft();
			int offset = Math.min(positionOffsetPixels, maxOffset - 1);
			mCurrent.setPadding(0, 0, 2 * offset, 0);
			 
			// Move previous text out of the way. Slightly buggy. 
			/* 
			int overlapLeft = mPreviousGroup.getRight() - mCurrent.getLeft() + mArrowPadding; 
			mPreviousGroup.setPadding(0, 0, Math.max(0, overlapLeft), 0); 
			mNextGroup.setPadding(0, 0, 0, 0); 
			*/ 
		}else{ 
			maxOffset -= this.getPaddingRight();
			int offset = Math.max(positionOffsetPixels, -maxOffset);
			mCurrent.setPadding(-2 * offset, 0, 0, 0);