我想使用動畫來縮放圖像。但它似乎也有一些問題,我不知道爲什麼會出現....android取消動畫導致stackoverflow錯誤
請幫我解決這個問題...
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;
}
});
我不知道什麼時候會在最終的動畫錯誤。請幫我
UPDATE:
OBJECT ANIMATOR CAN NOT用作其他動畫,它不能返回到原始大小如我所料。我想,如果其他人知道如何解決它,請教我出問題。很多謝謝
對不起,我只是更新代碼,我只是調用cancel()動畫。 – kemdo 2015-02-06 04:19:50
@kemdo'AnimatorSet.cancel()'也調用'onAnimationEnd(Animator)'。你必須從'onAnimationEnd'中移除'animatorSet.cancel();'。 – Suzi 2015-02-06 04:23:13
oke我把它刪除了,但是我怎麼才能把圖像的大小調整到原始大小..... – kemdo 2015-02-06 04:25:49