In my project, I had to make a rotation animation (it would pause and resume from the same / end position), and I solved it by getting the current time of the animator (when the animation ends / when I pause) and after starting the animator I set "setCurrentPlayTime ( with finite time). " To get the current time, I use getCurrentPlayTime (); and to set the time I use setCurrentPlayTime () of the ObjectAnimator class.
References: http://developer.android.com/reference/android/animation/ValueAnimator.html#setCurrentPlayTime(long) http://developer.android.com/reference/android/animation/ValueAnimator.html#getCurrentPlayTime ()
private ObjectAnimator mObjectAnimator; private long mAnimationTime; private void stopAnimation() { if(mObjectAnimator != null) { mAnimationTime = mObjectAnimator.getCurrentPlayTime(); mObjectAnimator.cancel(); } } private void playAnimation() { if (mObjectAnimator != null) { mObjectAnimator.start(); mObjectAnimator.setCurrentPlayTime(mAnimationTime); } }
source share