Gewusst wie: löschen Sie die animation in android?
In meiner android app die ich mache eine Schaltfläche-shake mit diesem code
public void FlashButton() {
final Button button = ((Button)findViewById(R.id.button_message));
final Animation moveright = AnimationUtils.loadAnimation(this, R.anim.moveright);
final Animation moveleft = AnimationUtils.loadAnimation(this, R.anim.moveleft);
final Animation moveright2 = AnimationUtils.loadAnimation(this, R.anim.moveright2);
AnimationListener animation1Listener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
button.startAnimation(moveleft);
}
};
AnimationListener animation2Listener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
button.startAnimation(moveright2);
}
};
AnimationListener animation3Listener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
button.startAnimation(moveright);
}
};
moveright.setAnimationListener(animation1Listener);
moveleft.setAnimationListener(animation2Listener);
moveright2.setAnimationListener(animation3Listener);
button.startAnimation(moveright);
}
Dieser code legt drei Animationen, die nacheinander in einer Schleife für immer.
Aber wie kann ich die animation anzuhalten, und stellen Sie die Taste wieder normal?
Versuchte ich .clearAnimation();
aber es hat nicht funktioniert...
Weiß jemand?
Dank.
- onAnimationEnd() funktioniert nicht
Du musst angemeldet sein, um einen Kommentar abzugeben.
Versuchen das Abbrechen der Animationen und sehen, so etwas wie
Versuchen oder zurücksetzen sowie
ähnlich wie für andere
Wenn Sie nicht lösen können das Problem aus welchem Grund auch immer, ich fand, dass das starten einer neuen reset-Typ-animation helfen können:
/> ....