【发布时间】:2015-09-20 15:24:39
【问题描述】:
我正在使用此代码旋转一个名为 photo 的 ImageView:
RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(400);
rotate.setFillEnabled(true);
rotate.setFillAfter(true);
rotate.setInterpolator(new LinearInterpolator());
rotate.setAnimationListener(new Animation.AnimationListener() {
});
photo.startAnimation(rotate);
它可以很好地旋转并持续存在。稍后我可能想更改此 ImageView 中的图片。但是,由于前一个图像上的持续动画,我的新图像出现旋转。如何在切换图像之前“撤消”此动画?
【问题讨论】:
-
也许这会对你有所帮助:stackoverflow.com/questions/4120824/…
-
尝试做反向动画,如果你不想让它动画,也许将持续时间设置为 0...
-
stopAnimation() 不工作?
-
stopAnimation() 无法正常工作,因为动画在很久以前就完成了。到目前为止,唯一可行的解决方案是创建一个持续时间为 0 的反向动画,但我不确定这是否是最好的解决方案......
标签: android