我正在尝试使用动画来缩放图像。但似乎有一些问题,我不知道它为什么会出现……
请帮我解决这个问题。
imgAlpha.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
List<Animator> animations = new ArrayList<Animator>();
animations.add(ObjectAnimator.ofFloat(imgAlpha,
View.SCALE_X, 2).setDuration(800));
animations.add(ObjectAnimator.ofFloat(imgAlpha,
View.SCALE_Y, 2).setDuration(800));
final AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(animations);
animatorSet.start();
animatorSet.setDuration(800);
animatorSet.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(final Animator animation) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
Logger.error("end animation");
animatorSet.cancel();
imgAlpha.clearAnimation();
}
@Override
public void onAnimationCancel(Animator animation) {
// TODO Auto-generated method stub
Logger.error("calcel animation");
}
});
return true;
}
});我不知道它何时会在结束动画时导致错误。请帮帮我
更新:
对象动画师不能像其他动画一样使用,它不能像我期望的那样恢复到原来的大小。我想是的,如果其他人知道如何解决它,请教我解决问题。非常感谢
发布于 2015-02-06 12:16:10
AnimatorSet.end()会触发onAnimationEnd(Animator),因此会产生一个递归。
请参阅documentation
结束动画。这会导致动画将被动画的属性的结束值赋值,然后在其侦听器上调用onAnimationEnd(Animator)方法。
https://stackoverflow.com/questions/28358429
复制相似问题