我想让一个图标在我点击它时旋转,就像一个进度条一样,然后当我的应用程序完成按钮的意思时,它停止旋转。
我想拍摄一个像这样的图像:https://www.google.co.za/search?q=refresh+icon&safe=off&espv=2&es_sm=122&tbm=isch&tbo=u&source=univ&sa=X&ei=kaomU8mWC4eshQe7soHgAQ&ved=0CCoQsAQ&biw=1920&bih=912
我可以更改进度条的图像吗?
我尝试了一个动画,但是我没有让它工作,
我最好的选择是什么?
rotateAnimation = new RotateAnimation(0, 359,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
rotateAnimation.setRepeatCount(Animation.INFINITE);
rotateAnimation.setRepeatMode(Animation.RESTART);
编辑:<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<rotate
android:duration="1000"
android:repeatCount="infinite"
android:repeatMode="restart"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="0.5"
android:pivotY="0.5"
/>
</set>
我试过这样做,它对我来说很有效:
rotateAnimation = new RotateAnimation(0, 359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation.setRepeatCount(Animation.INFINITE);
rotateAnimation.setRepeatMode(Animation.RESTART);
rotateAnimation.setDuration(1000);
ImageView iv = (ImageView) findViewById(R.id.img);
iv.startAnimation(rotateAnimation);
我想你错过了duration
…
使用50%
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<rotate
android:duration="1000"
android:repeatCount="infinite"
android:repeatMode="restart"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
/>