Ich habe ein Animator, infinite_rotation
, definiert als:ObjectAnimator mit endloser Rotation stottert
<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>
Wenn die Zeit (Zeit unbestimmt ist) kommt, dass ich nicht diese länger brauchen, rufe ich infinite_animator.cancel()
. Dann spielen eine fade_out Animation auf dem Layoutcontainer:
<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>
Die resultierende Animation ist, dass die Drehung wie erwartet stoppt aber stottert während ausblenden. Was vermisse ich?
Hier ist, wie es aussieht:
UPDATE: Ich teste das oben beschriebene Problem auf alt Samsung Tab 4 mit Kitkat OS. Ich habe gerade auf einem etwas neueren Samsung Tab 4 mit Marshmallow OS getestet. Die Animation funktioniert gut. Ich denke also, die bessere Frage ist, wie repariere ich die schlampige Animation auf meinem älteren Gerät/Betriebssystem?
Dies ist die Animation Aufruf:
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()
ausgelöst wird, wenn die App Refresh abgeschlossen ist bestimmt. Dies ist der Aufruf abzubrechen und 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();
}
Haben Sie versucht, fillAfter für Ihre Rotationsanimation auf True zu setzen? – algrid
nein. Ich kann das ausprobieren. Vielen Dank. – user1506104
Können Sie ein gif dieses Verhaltens veröffentlichen? – azizbekian