2

In the ViewHolder of my RecyclerView, I have a method that is called to animate the alpha value of one of its TextViews. The ViewHolders are registered to a global notifier in onBindViewHolder and unregistered in onViewRecycled. When notified, all visible ViewHolders run the animation immediately. Those that are binded to but not currently visible end up delaying the animation until it's visible. My expectation would be that the animation for these ViewHolders would have either already started, or would be skipped entirely.

I've also created a Gist for the class used in the example.

My fix is to only run the animation for ViewHolders that are visible. I'm asking this question mostly for enlightenment and also to make sure I'm not missing something here.

enter image description here

jpetitto
  • 331
  • 4
  • 15

1 Answers1

0

You should use ItemAnimators

https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ItemAnimator.html

Example code: https://github.com/wasabeef/recyclerview-animators

George Wu
  • 1
  • 1
  • These are only useful for adapter changes (e.g. adding/removing items) or animations on scroll. My question is regarding normal view animations which happen inside of a ViewHolder's view (not the entire item itself). I'll update the question with some code and perhaps enhance the example, because the screenshot I'm showing is a stripped down version (there are other elements in my real example which don't animate). – jpetitto Mar 05 '18 at 23:43