我有关于这一点我已经应用了旋转动画的ImageView的。因为我想旋转持续下去的话,我给的repeatCount是无限的在我的rotate.xml:
I have an ImageView on which I have applied a rotate animation. Since I want the rotation to go on continuously, I gave the repeatCount as infinite in my rotate.xml:
android:repeatCount="infinite"
在的onCreate(),我加载动画,并启动它。
In onCreate(), I load the animation and start it.
Animation myAnim = AnimationUtils.loadAnimation(this, R.anim.rotate);
objectImg.startAnimation(myAnim);
当一个按钮pssed $ P $,旋转必须停止。因此,在我的onClick(),我叫clearAnimation()。
When a button is pressed, the rotation must stop. Hence in my onClick(), I called clearAnimation().
objectImg.startAnimation(myAnim);
我的简单的问题是,是否停止动画是正确的事情。 我假定clearAnimation()对应loadAnimation(),但也有是对应于startAnimation()。
My simple question is whether stopping the animation is the right thing to do. I assume clearAnimation() corresponds to loadAnimation(), but there is no stopAnimation() that corresponds to startAnimation().
您也可以拨打 anim.cancel();
但你也应该叫 anim.reset();
紧随其后。
然后,当你想再次启动它,只需拨打 startAnimation
的看法。
You can also call anim.cancel();
but you should also call anim.reset();
immediately after it.
Then when you want to start it again, just call startAnimation
on the view.