I am trying to do some animation inside ViewPager2 with Fragments.
But the problem is when I load the animation from XML, it is working for the first time. After swiping left/right in ViewPager and going back to the same page that animation is not working.
Below is the XML anim
<?xml version="1.0" encoding="UTF-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:interpolator="@android:anim/linear_interpolator"
android:duration="4000" />
Below is the code which I used to load the animation inside Fragment
Animation rotate = AnimationUtils.loadAnimation(getContext(), R.anim.rotate);
view.startAnimation(rotate);
I have also done some animation without loading from XML, it was working perfectly fine. That problem only occurs when I load the animation from XML.