Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中制作旋转刷新图标_Android_Rotation_Progress Bar_Android Animation - Fatal编程技术网

如何在android中制作旋转刷新图标

如何在android中制作旋转刷新图标,android,rotation,progress-bar,android-animation,Android,Rotation,Progress Bar,Android Animation,当我点击图标时,我想让它旋转,就像进度条一样,然后当我的应用程序完成按钮的功能后,它就停止旋转 我想拍摄这样的am图像: 我可以更改进度条的图像吗 我试过一部动画,但没有成功 我最好的选择是什么 rotateAnimation = new RotateAnimation(0, 359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAni

当我点击图标时,我想让它旋转,就像进度条一样,然后当我的应用程序完成按钮的功能后,它就停止旋转

我想拍摄这样的am图像:

我可以更改进度条的图像吗

我试过一部动画,但没有成功

我最好的选择是什么

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 = 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);

我认为您错过了
持续时间

围绕中心旋转使用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%"         
   />


如何将其更改为xml版本?因为没有数据透视类型和数据透视值。仅pivot?我不认为所有元素都可以在xml中设置。为什么需要它?因为否则它会围绕顶点x:0 y:0旋转。到目前为止,我在编辑中看到了什么?您是否尝试在xml中添加了
android:interpolator=“@android:anim/linear\u interpolator”
?是的。这没用。它围绕点x=0旋转;y=0。我需要它围绕中间旋转。
<?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%"         
   />