android判断动画已结束示例代码

时间:2022-09-20 16:04:28

添加一个动画效果

发现动画没执行完 就直接跳转或者finish掉

添加动画监听事件即可,代码如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
player.startAnimation(anim);
anim.setAnimationListener(new AnimationListener() {
 
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
 
}
 
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
 
}
 
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
finish();
}
});
 
overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
player.startAnimation(anim);
anim.setAnimationListener(new AnimationListener() {
 
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
 
}
 
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
 
}
 
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
finish();
}
});
 
overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);

在onAnimationEnd 添加自己想要的动作就行