Android刷新转圈动画实现(一)
16lz
2022-07-24
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"><rotateandroid: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);}
更多相关文章
- 箭头函数的基础使用
- NPM 和webpack 的基础使用
- Python list sort方法的具体使用
- 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
- 读取android手机流量信息
- android 使用html5作布局文件: webview跟javascript交互
- Android(安卓)多媒体扫描过程(Android(安卓)Media Scanner Proces
- android“设置”里的版本号
- Android开发环境搭建