I have this simple arrow image rotation animation that only works as intended. second time forward. It still rotates, but without slow animation.

Here is the code in the XML animation files
Rotate 180
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1500" android:fromDegrees="0" android:toDegrees="180" android:interpolator="@android:anim/linear_interpolator" android:pivotX="50%" android:pivotY="50%" android:repeatCount="0" android:fillAfter="true" android:fillEnabled="true"/>
Turn Revere
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1500" android:fromDegrees="180" android:toDegrees="0" android:interpolator="@android:anim/linear_interpolator" android:pivotX="50%" android:pivotY="50%" android:repeatCount="0" android:fillAfter="true" android:fillEnabled="true" />
The image inside the map.
<ImageView android:id="@+id/creadit_card_next_image" android:layout_width="@dimen/next_image_size" android:layout_height="@dimen/next_image_size" android:layout_marginEnd="@dimen/static_menu_primary_margin" android:layout_marginTop="16dp" android:rotation="-90" android:src="@drawable/ic_navigate_next" android:tint="@color/colorPrimary" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" />
Java code to run the animation.
private Animation rotatePlus180; private Animation rotateMinus180; private boolean creditDebitCardViewExpanded = true; rotatePlus180 = AnimationUtils.loadAnimation(this, R.anim.rotate_plus_180); rotateMinus180 = AnimationUtils.loadAnimation(this, R.anim.rotate_minus_180); private void onClickCreditDebitCardView() { creditDebitCardPaymentMethod.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (creditDebitCardViewExpanded) { expandAnimation(paymentRecyclerView); creditDebitCardViewExpanded = false; creditCardNextImage.setAnimation(rotatePlus180); } else { collapseAnimation(paymentRecyclerView); creditDebitCardViewExpanded = true; creditCardNextImage.setAnimation(rotateMinus180); CreditDebitLayoutContainer.setPadding(0, 0, 0, padding); } } }); }
source share