我有一个 ImageView,我在其上应用了旋转动画。由于我希望旋转连续进行,因此我在我的 rotate.xml 中将 repeatCount 设为无限:
android:repeatCount="infinite"
在 onCreate() 中,我加载动画并启动它。
Animation myAnim = AnimationUtils.loadAnimation(this, R.anim.rotate);
objectImg.startAnimation(myAnim);
按下按钮时,旋转必须停止。因此在我的 onClick() 中,我调用了 clearAnimation()。
objectImg.startAnimation(myAnim);
我的简单问题是停止动画是否正确。 我假设 clearAnimation() 对应于 loadAnimation(),但没有 stopAnimation() 对应于 startAnimation()。
最佳答案
使用 clearAnimation()
停止动画。 View
上没有loadAnimation()
。
关于Android:如何停止在 ImageView 上应用的无限动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3913750/