我有一个简单的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()时,有没有可能将动画“冻结”在它结束的任何帧(或它所处的角度),而不是将它重置到第一帧?
发布于 2012-01-13 13:13:20
您最好将图像内容包装在RotateDrawable中,并将其设置为ImageView,而不是使用动画。您仍然可以通过使用简单的处理程序重复调用setImageLevel()来调整旋转角度来设置变换的动画。
当冻结动画的时间到来时,只需停止发布到Handler,图像将保持在其最后设置的级别值。然后,如果您愿意,可以通过恢复到Handler的帖子来重新启动。
另一种选择是创建自定义ViewGroup并使用getChildStaticTransformation()对子ImageView应用自定义转换。您仍将手动处理动画步骤,因此可以在您喜欢的任何点启动/停止,但动画系统使用Transformation来设置视图动画,因此您可能会获得更接近该效果的结果。
HTH
发布于 2013-01-04 05:25:12
我有一个应用程序,必须保持其旋转位置后,得到其确定的角度。我找了很长时间,最后发现调用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);https://stackoverflow.com/questions/8846125
复制相似问题