只设置Offset的话,在reverse前也会停留。
AlphaAnimation animationOffset = new AlphaAnimation(1.0f,0.2f);
animationOffset.setDuration(700);
animationOffset.setRepeatMode(Animation.REVERSE);
animationOffset.setRepeatCount(Animation.INFINITE);
animationOffset.setAnimationListener(new Animation.AnimationListener() {
boolean reverse = true;
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
if(reverse){
reverse = false;
animation.setStartOffset(0);
}else{
reverse = true;
animation.setStartOffset(2000);
}
}
});
batteryIV.clearAnimation();//清除动画 batteryIV.startAnimation(animationOffset);