我有一系列动画,我按照这样的方式调用:
final Animation anim1 = AnimationUtils.loadAnimation(thisObject, R.anim.animation1);
final Animation anim2 = AnimationUtils.loadAnimation(thisObject, R.anim.animation2);
final Animation anim3 = AnimationUtils.loadAnimation(thisObject, R.anim.animation3);
final Animation anim4 = AnimationUtils.loadAnimation(thisObject, R.anim.animation4);
anim1.setAnimationListener(new AnimationListener()
{
public void onAnimationStart(Animation animation) { }
public void onAnimationRepeat(Animation animation) { }
public void onAnimationEnd(Animation animation)
{
image.startAnimation(anim2);
}
});
anim2.setAnimationListener(new AnimationListener()
{
public void onAnimationStart(Animation animation) { }
public void onAnimationRepeat(Animation animation) { }
public void onAnimationEnd(Animation animation)
{
image.startAnimation(anim3);
}
});
// etc...
view.startAnimation(anim1);
虽然这样可行,但图像会在每个动画之间瞬间快速恢复到原始位置。我在所有动画XML文件中都将android:fillAfter
定义为true
,但这似乎没有任何改变。有没有办法阻止动画之间的这种快照?或者有更好的方法来达到同样的效果吗?