How to reset view to original state after using animators to animates its some properties?

Napolean picture Napolean · Jun 16, 2015 · Viewed 7.1k times · Source

I am using animators (ObjectAnimator) to animate few properties (scale, rotate) of a view.

Target view is animating properly when ObjectAnimators are set to it.

But there is an added requirement to get view to the original position (reset) after a while.

I tried to cancel() the animator but it only cancels the animation and doesn't reset the view.

Possible solution : creating another animator that does just opposite of the initial animator.

Is there any other way to reset it ?

Answer

Alon picture Alon · Aug 16, 2017

See the solution I came up with as I had a similar issue with animations inside views in a recycler view, so I had to find a way to reset them:

Trying to reset values from Property Animator to be used in recycler view

Good news in Android O these will be better supported