public void changeAnimation ( ViewHolder oldHolder , ViewHolder newHolder , int fromX , int fromY , int toX , int toY ) { final float prevTranslationX = ViewCompat . getTranslationX ( oldHolder . itemView ) ; final float prevTranslationY = ViewCompat . getTranslationY ( oldHolder . itemView ) ; final float prevValue = ViewCompat . getAlpha ( oldHolder . itemView ) ; resetAnimation ( oldHolder ) ; int deltaX = ( int ) ( toX - fromX - prevTranslationX ) ; int deltaY = ( int ) ( toY - fromY - prevTranslationY ) ; // recover prev translation state after ending animation ViewCompat . setTranslationX ( oldHolder . itemView , prevTranslationX ) ; ViewCompat . setTranslationY ( oldHolder . itemView , prevTranslationY ) ; ViewCompat . setAlpha ( oldHolder . itemView , prevValue ) ; if ( newHolder != null ) { // carry over translation values resetAnimation ( newHolder ) ; ViewCompat . setTranslationX ( newHolder . itemView , - deltaX ) ; ViewCompat . setTranslationY ( newHolder . itemView , - deltaY ) ; ViewCompat . setAlpha ( newHolder . itemView , 0 ) ; } }
the whole change animation if we have to cross animate two views