private void setTranslate ( float x , float y ) { if ( Math . abs ( x ) > 1 || Math . abs ( y ) > 1 ) { throw new IllegalArgumentException ( "Parallax effect cannot translate more than 100% of its off-screen size" ) ; } float xScale , yScale ; if ( mScaledIntensities ) { // Set both scales to their offset values xScale = mXOffset ; yScale = mYOffset ; } else { // Set both scales to the max offset (should be negative, so smaller absolute value) xScale = Math . max ( mXOffset , mYOffset ) ; yScale = Math . max ( mXOffset , mYOffset ) ; } // Make sure below maximum jump limit if ( mMaximumJump > 0 ) { // Limit x jump if ( x - mXTranslation / xScale > mMaximumJump ) { x = mXTranslation / xScale + mMaximumJump ; } else if ( x - mXTranslation / xScale < - mMaximumJump ) { x = mXTranslation / xScale - mMaximumJump ; } // Limit y jump if ( y - mYTranslation / yScale > mMaximumJump ) { y = mYTranslation / yScale + mMaximumJump ; } else if ( y - mYTranslation / yScale < - mMaximumJump ) { y = mYTranslation / yScale - mMaximumJump ; } } mXTranslation = x * xScale ; mYTranslation = y * yScale ; configureMatrix ( ) ; }
Sets the image view s translation coordinates . These values must be between - 1 and 1 representing the transaction percentage from the center .