添加旋转动画:
在res中建立anim文件夹,然后在anim文件夹建立xml文件rotate_jiantou_down_to_up,如图;
<?xmlversion="1.0"encoding="utf-8"?>
<?xmlversion="1.0"encoding="utf-8"?>
<rotatexmlns:android="http://schemas.android.com/apk/res/android"
android:duration="250"
android:fillAfter="true"
android:fromDegrees="0"
android:toDegrees="180"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="0"
>
</rotate>
<!--
duration 动画执行的时间
fillAfter 当动画结束的时候,控件的位置停在动画的最后一帧;
(谷歌文档)If fillAfter is true, the transformation that this animation performed will persist when it is finished.
fromDegrees 旋转动画的起始角度
toDegrees 动画结束的角度
pivotX 旋转的中心点,x坐标,以该坐标旋转
pivotY 旋转的中心点,y坐标,以该坐标旋转
repeatCount 重复次数
-->
在代码中引用
RotateAnimation mRotateAnimation = (RotateAnimation) AnimationUtils.loadAnimation(getContext(), R.anim.rotate_jiantou_down_to_up);
mRefresh_head_jiantou= (ImageView) findViewById(R.id.refresh_head_jiantou);
// 添加匀速转动动画
LinearInterpolator lir = new LinearInterpolator();
mRotateAnimation.setInterpolator(lir);
//播放动画
mRefresh_head_jiantou.startAnimation(mRotateAnimation);