ome*_*ega 4 java animation android
在我的Android应用程序中,我使用此代码进行按钮抖动
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);
}
Run Code Online (Sandbox Code Playgroud)
此代码永远在循环中按顺序设置三个动画.
但是如何停止动画,再次使按钮正常?
我试过.clearAnimation();但它不起作用......
有人知道吗?
谢谢.
尝试取消动画并查看类似的内容
moveright.cancel();
moveright2.cancel();
moveleft.cancel();
Run Code Online (Sandbox Code Playgroud)
或者尝试重置
moveright.reset();
Run Code Online (Sandbox Code Playgroud)
与其他人相似
| 归档时间: |
|
| 查看次数: |
7348 次 |
| 最近记录: |