I need to animate a particular item update. In RecyclerView we can use ItemAnimator for such animation. What can we use for ViewPager2?
Asked
Active
Viewed 432 times
1 Answers
0
You would use a ViewPager2.PageTransformer
, to animate the Fragments when they are swapped between.
Here is a link containing some cool animation.
Due note these are for ViewPager
not ViewPager2
, so you will have to modify them a bit. Luckily the interface has same signatures so it should be straight forward.
I've personally used two of them and they work great.
The only thing you will have to look out for is depth based animations TranslationZ
those require API 21, if that's an issue for you.

avalerio
- 2,072
- 1
- 12
- 11
-
Thanks, I've tried that, it is useful when we scroll the page (left or right) but does not work for item update. I need something like https://developer.android.com/reference/androidx/recyclerview/widget/DefaultItemAnimator so that I can override animateChange function – Mukhtar Bimurat Dec 14 '21 at 16:39
-
@avalerio can you please check this [issue](https://stackoverflow.com/q/70593277/11560810) – Kotlin Learner Jan 05 '22 at 18:44