登录

去注册 忘记密码?

登录

注册

去登录

  • 扫码关注公众号
  • 发送“我爱安卓
  • 即可获取验证码

注册

解锁回答区域

  • 扫码关注公众号
  • 发送“我爱安卓

若你登陆,将永久解锁;
若未登录,仅本机解锁。

解锁回答区域

获取注册验证码

  • 扫码关注公众号
  • 发送“我爱安卓
  • 即可获取验证码

CoffeeDrawable(搅拌咖啡下拉刷新动画)

wuyr   2019-10-13 23:47   收藏

CoffeeDrawable,纯Paint实现的一个搅拌咖啡效果,可用作Loading动画。

博客详情: https://blog.csdn.net/u011387817/article/details/100530256

使用方式:

添加依赖:

● 单独使用Drawable

implementation 'com.wuyr:coffeedrawable:1.0.0'

● 作为刷新Header (需配合SmartRefreshLayout使用)

implementation 'com.wuyr:coffeeheader:1.0.1'

APIs:

CoffeeDrawable

MethodDescription
create(View targetView)创建对象
targetView: 显示此Drawable的容器,下同
create(View targetView, int cupRadius)指定杯子半径来创建对象
create(int width, int height)指定Drawable的宽高来创建对象
create(int width, int height, int cupRadius)指定Drawable的宽高和杯子半径来创建对象
start()开始播放搅拌动画
finish()结束播放搅拌动画
reset()重置状态
setProgress(float progress)设置移动进度

CoffeeDrawable & CoffeeHeader

MethodDescription
updateSize(int width, int height, int cupRadius)更新CoffeeDrawable的尺寸
setCupBodyColor(int color)设置杯身颜色
setCupBottomColor(int color)设置杯底颜色
setCoffeeColor(int color)设置咖啡颜色
setHandColor(int color)设置手颜色
setStickColor(int color)设置搅拌棒颜色
setStirringDuration(long duration)设置搅拌一圈的时长 (默认: 500)
setHideDuration(long duration)设置隐藏手臂动画时长 (默认: 300)
setEdgeFadeDuration(long duration)设置咖啡边缘渐变动画时长 (默认: 500)

Attributes:

CoffeeHeader

NameFormatDescription
coffeeColorcolor (默认: 咖啡色)咖啡颜色
cupBodyColorcolor (默认: 白色)杯身颜色
cupBottomColorcolor (默认: 青色)杯底颜色
handColorcolor (默认: 棕黄)手颜色
stickColorcolor (默认: 白色)搅拌棒颜色
cupRadiusdimension (默认: 总宽度的1/15)杯子半径

Demo下载: app-debug.apk

库源码地址:

● CoffeeDrawable: https://github.com/Ifxcyr/CoffeeDrawable

● CoffeeHeader: https://github.com/Ifxcyr/CoffeeHeader

效果图:

preview preview

项目地址:https://github.com/wuyr/CoffeeDrawable