我有一个简单的RotateAnimation
来无限期地为ImageView
设置动画,直到我停止它。我的动画设置如下:
Animation spin = new RotateAnimation(0.0f, 1800.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
spin.setInterpolator(new LinearInterpolator());
spin.setRepeatCount(Animation.INFINITE);
spin.setDuration(5000);
imageView.setAnimation(spin);
当我调用imageView.cancelAnimation()
时,我是否可以将动画“卡住”在它结束的任何帧(或它所在的任何角度),而不是将其重置为第一帧?
最佳答案
我有一个应用程序,在达到确定的角度后必须保持其旋转位置。我搜索了很长一段时间,终于发现调用 setFillAfter() 方法。这将阻止旋转重置。
RotateAnimation rotate = new RotateAnimation(startingPoint, value, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
image.setAnimation(rotate);
rotate.setDuration(ROTATION_INTERVAL);
rotate.setFillAfter(true);
关于android - 防止旋转动画在取消时重置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8846125/