我有一个imageview图层,我想要将它旋转一下并停下来,当我再次触摸时,我该怎么办?Android - 如何在图像上旋转图像查看
-2
A
回答
1
在动画 DIR
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<rotate
android:duration="2500"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toDegrees="360" />
</set>
现在,在你的类文件加载动画
Animation animation = AnimationUtils.loadAnimation(getContext(),R.anim.rotate);
而且对你的形象点击开始动画创建动画rotate.xml
your_image.startAnimation(animation);
+0
感谢和最后一个问题如果我再次触摸需要停止动画的图像,我该如何处理? – kingmaker
+0
采取一个布尔isAnimationRunning,并在动画开始时将其设置为true,反之亦然。如果没有运行,则只需单击图像即可开始动画。 –
0
您可以尝试以编程方式设置动画这样的:
RotateAnimation rotate = new RotateAnimation(0, 360,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
rotate.setDuration(4000);
rotate.setRepeatCount(Animation.INFINITE);
yourView.setAnimation(rotate);
希望它能帮助。
+0
如何做ontouch旋转和ontouch再次停止旋转? – kingmaker
相关问题
- 1. Android旋转图像
- 2. Android旋转图像
- 3. 在背景图像上旋转图像
- 4. Android图像旋转木马查看(感觉像)
- 5. Android ||位图图像旋转
- 6. 随机旋转图像查看
- 7. 旋转图像查看随机
- 8. 如何在圆周上旋转图像?
- 9. 如何在Android中旋转图像?
- 10. 点在旋转图像上拖曳 - android
- 11. 在图像上查找区域 - 自动旋转图像OpenCv
- 12. android - 图片旋转在图像按钮
- 13. Android:如何使用Fresco旋转图像
- 14. Android ImageView检查图像旋转吗?
- 15. Android,帮助旋转图像
- 16. Android旋转图像ontouch
- 17. 的Android - 旋转图像
- 18. Android大图像旋转
- 19. Android的图像旋转
- 20. 如何旋转图像?
- 21. 如何旋转图像帧?
- 22. 如何旋转图像wpf
- 23. 旋转图像
- 24. - 旋转图像
- 25. 旋转图像
- 26. 旋转图像
- 27. 旋转图像
- 28. 旋转图像
- 29. Android:打印图像查看图像
- 30. 如何旋转iPhone上的图像?
同样的问题被回答在这里 - http://stackoverflow.com/questions/8981845/android-rotate-image-in-imageview-by-an-angle –