0

I'm doing a simple animation of an icon in an ImageView that is inside an ExpandableRecyclerAdapter. When clicking on the expansion item, the animation starts but returns to the initial state, presenting a different behavior. It starts to rotate from 0F to 180F, but at the end it returns from where it was as seen below:

ImageView

I'm using AnimationUtils and two xml files -> one to rotate 180 degrees for the up arrow and -180 for it to return;

My rotation function:

fun rotateAnimation(view: View, expanded: Boolean) {
    var anim = AnimationUtils.loadAnimation(view.context, R.anim.rotate_view_up)

    if (expanded) {
        view.startAnimation(anim)
    } else {
        anim = AnimationUtils.loadAnimation(view.context, R.anim.rotate_view_down)
        view.startAnimation(anim)
    }
}

My XML animation files are configured as seen below (arrow up):

<rotate
    android:duration="1000"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:fillAfter="true"
    android:interpolator="@android:anim/cycle_interpolator"
    android:toDegrees="-180" />

Arrow down(ony toDegree change):

<rotate
    android:duration="1000"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:fillAfter="true"
    android:interpolator="@android:anim/cycle_interpolator"
    android:toDegrees="180" />

Is there any configuration I missed in the xml set?

duhspbr
  • 21
  • 2
  • 1
    same question, [the answer link](https://stackoverflow.com/questions/6510300/fillafter-and-fillenabled-not-working-in-android-view-animation-xml) – pan he Oct 09 '22 at 09:52

0 Answers0