赞
踩
需求是ui给的多张图片实现动画效果,并且下拉的时候动画不断变化,回退时,刷新动画效果也跟着回退,下拉刷新松手时,刷新动画循环播放,直至数据出来为止,话不多说,直接上效果图
首先,先添加依赖
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.2'
自定义刷新动画,在res下drawable下创建一个animation_refresh.xml文件,代码如下,大家可以直接将我的图片替换掉
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true"> <item android:drawable="@mipmap/ic_refresh1" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh2" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh3" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh4" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh5" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh6" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh7" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh8" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh9" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh10" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh11" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh12" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh13" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh14" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh15" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh16" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh17" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh18" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh19" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh20" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh21" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh22" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh23" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh24" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh25" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh26" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh27" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh28" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh29" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh30" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh31" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh32" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh33" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh34" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh35" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh36" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh37" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh38" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh39" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh40" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh41" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh42" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh43" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh44" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh45" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh46" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh47" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh48" android:duration="30" /> <item android:drawable="@mipmap/ic_refresh49" android:duration="30" /> </animation-list>
在自己的application中配置;
public class BCApplication extends Application
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。