我有一个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. 在android中旋转图像
- 4. 旋转图像查看随机
- 5. 如何在Android中旋转图像?
- 6. 点在旋转图像上拖曳 - android
- 7. android - 图片旋转在图像按钮
- 8. Android的图像旋转
- 9. Android大图像旋转
- 10. 的Android - 旋转图像
- 11. Android,帮助旋转图像
- 12. 如何旋转图像wpf
- 13. 如何旋转图像?
- 14. - 旋转图像
- 15. 旋转图像
- 16. 旋转图像
- 17. 旋转图像
- 18. 旋转图像
- 19. 如何旋转iPhone上的图像?
- 20. 图像上的3D旋转
- 21. 在图像中旋转图像
- 22. 如何在JAVA中旋转图像?
- 23. 旋转图像查看时间可持续在机器人
- 24. 在RemoteViews中旋转图像?
- 25. 如何转换MapTile图像以查看
- 26. 像UIPicker旋转图像VIew
- 27. 在整个屏幕上旋转图像
- 28. 如何查看Android中的图像
- 29. Android Studio:搜索查看图像,如何?
- 30. Android:如何更改GridView图像,同时单击图像查看
同样的问题被回答在这里 - http://stackoverflow.com/questions/8981845/android-rotate-image-in-imageview-by-an-angle –