您的位置:首页 > 移动开发 > Android开发

Android刷新转圈动画实现(一)

2016-03-23 14:07 169 查看
1.XML文件中:

\res\anim\anim_rotate_refresh.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="1000"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toDegrees="360"/>
</set>


2.Java文件中使用:

private ImageView mRefresh;
private Animation mRefreshAnim;

mRefresh = (ImageView) findViewById(R.id.search_refresh);
mRefreshAnim = AnimationUtils.loadAnimation(mContext, R.anim.anim_rotate_refresh);

public void stopAnim() {
mRefreshAnim.reset();
mRefresh.clearAnimation();
mRefresh.setBackgroundResource(R.drawable.search);
}

public void startAnim() {
mRefreshAnim.reset();
mRefresh.clearAnimation();
mRefresh.setBackgroundResource(R.drawable.search_refresh);
mRefresh.startAnimation(mRefreshAnim);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: