J'ai un animateur, infinite_rotation
, défini comme:ObjectAnimator avec rotation infinie bégaie
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:propertyName="rotation"
android:repeatCount="infinite"
android:valueFrom="0"
android:valueTo="360"
android:duration="2000" />
</set>
Lorsque le temps (le temps est indéfini) vient que je ne avez plus besoin, je l'appelle infinite_animator.cancel()
. Ensuite, jouer une animation fade_out sur son récipient de mise en page:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:propertyName="alpha"
android:repeatCount="0"
android:valueTo="0.0"
android:duration="1000" />
</set>
L'animation résultante est que la rotation arrête comme prévu, mais bégaie tout en estomper. Qu'est-ce que je rate?
Voici à quoi il ressemble:
MISE À JOUR: je testais le problème ci-dessus sur l'ancien Tab Samsung 4 avec KitKat OS. Je viens de tester sur un Samsung Tab 4 assez récent avec OS Marshmallow. L'animation fonctionne bien. Donc, je suppose que la meilleure question est de savoir comment réparer l'animation bâclée sur mon ancien appareil/système d'exploitation?
C'est l'appel d'animation:
private void animateRefreshButton() {
ImageView iv_refresh = (ImageView) findViewById(R.id.iv_refresh);
if(infinite_animator == null) {
infinite_animator = AnimatorInflater.loadAnimator(this, R.animator.refresh_rotate);
}
infinite_animator.setTarget(iv_refresh);
infinite_animator.start();
}
hideRefreshButton()
est déclenchée lorsque l'application détermine l'actualisation est terminée. Ceci est l'appel d'annuler et fade out animation:
private void hideRefreshButton() {
if(infinite_animator != null) {
infinite_animator.cancel();
}
Animator anim = AnimatorInflater.loadAnimator(this, R.animator.refresh_fadeout);
anim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {}
@Override
public void onAnimationEnd(Animator animation) {
framelayout_container_of_iv_refresh.setVisibility(View.GONE);
}
@Override
public void onAnimationCancel(Animator animation) {}
@Override
public void onAnimationRepeat(Animator animation) {}
});
anim.setTarget(framelayout_container_of_iv_refresh);
anim.start();
}
Avez-vous essayé de définir fillAfter sur true pour votre animation de rotation? – algrid
no. Je peux essayer ça. Merci. – user1506104
Pouvez-vous poster un gif de ce comportement? – azizbekian