Skip to content Skip to sidebar Skip to footer

Trying To Reset Values From Property Animator To Be Used In Recycler View

Been doing some animation inside of a row in RecyclerView (not the row itself. Imagine expanding text) and there are times when the animation leaks to other recycled views which sh

Solution 1:

4 days and not one response but meanwhile I solved it myself. So the approach was close, just wrongly placed.

I added this method:

private void stopAnimation() {
    for (Animator anim : mTotalAnimation.getChildAnimations()) {
        ((ObjectAnimator) anim).reverse();
        anim.end();
    }
}

and I call that when I want to reset the view.

Here I am getting the animations from the AnimatorSet and reversing and ending each. I did not understand why I had to do it manually but it looks like this ability will be added in Android O: https://developer.android.com/preview/api-overview.html#aset

Starting in Android O, the AnimatorSet API now supports seeking and playing in reverse. Seeking lets you set the position of the animation set to a specific point in time. Playing in reverse is useful if your app includes animations for actions that can be undone. Instead of defining two separate animation sets, you can play the same one in reverse.

Post a Comment for "Trying To Reset Values From Property Animator To Be Used In Recycler View"