我有一個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 –