一个项目玩转 Android 自定义 Drawable。

DreamDrawable

项目地址:yanbober/DreamDrawable 

简介: 一个项目玩转 Android 自定义 Drawable。

更多:作者   提 Bug   

标签:

 

一个项目玩转 Android 自定义 Drawable,具体原理参见《Android 应用层开发 Drawable 的一些叨叨絮》,效果如下图所示。

说明文档

当前实现了多个 Customer Drawable,依据自己情况使用其一即可,互相无任何依赖。

类型定义说明
RoundDrawableRoundDrawable圆角 Drawable,可实现类似上图中第一行各种效果。
方法RoundDrawable(Bitmap bitmap)构造方法直接传递一个 Bitmap 即可,然后使用即可,譬如 ImageView.setImageDrawable(drawable);
ReflectionDrawableReflectionDrawable底部具备倒影效果的 Drawable,可以实现类似上图中第二行各种效果等。
方法ReflectionDrawable(Bitmap bitmap)构造方法直接传递一个 Bitmap 即可,然后使用即可,譬如 ImageView.setImageDrawable(drawable);
方法setReflectionHeight(@IntRange(from = 0) int height)给 ReflectionDrawable 设置底部反转倒影的高度。
LauncherIconDrawableLauncherIconDrawable具备进度刷新效果的 Drawable,譬如 miui 桌面 app 更新图标进度,类似上图第三行等效果,还可配置。譬如 ImageView.setImageDrawable(drawable);
方法LauncherIconDrawable(Drawable drawable)构造方法传递一个 Drawable,譬如传递 ImageView.getDrawable();
方法setDefaultColor(@ColorInt int defaultColor)设置 LauncherIconDrawable 中图片默认的覆盖颜色,模式为 PorterDuff.Mode.MULTIPLY。
方法setDefaultColor(@ColorInt int defaultColor, PorterDuff.Mode mode)同上,设置 LauncherIconDrawable 中图片默认的覆盖颜色。
方法setPercentColor(@ColorInt int percentColor)设置 LauncherIconDrawable 中进度的覆盖颜色,模式为 PorterDuff.Mode.MULTIPLY。
方法setPercentColor(@ColorInt int percentColor, PorterDuff.Mode mode)同上,设置 LauncherIconDrawable 中进度的覆盖颜色。
方法setCurPercent(@FloatRange(from = 0f, to = 1f) float curPercent)设置当前进度为多少,类似 miui App 更新桌面图标进度更新。
IconViewIconView类似 Flyme 6.0 联系人 Icon 的 Drawable 的 View,可以实现类似上图中最后一行的各种效果,配合下面的 IconDrawable 使用。
方法IconDrawable getIconDrawable()获取 IconView 中的 IconDrawable 来使用。
IconDrawableIconDrawable配合上面 IconView 内部使用的,不用自己 new,只用通过 IconView 的 IconDrawable getIconDrawable() 获取来操作。
方法setTextLabel(String str)设置文字,譬如联系人姓或者首字母等。
方法setTextFontSize(int size)设置文字大小,不设置默认会自适应。
方法setTextColor(int color)设置文字颜色。
方法setBackgroundColor(int color)设置为文字时的背景颜色。
方法setIconLabel(Bitmap bitmap)设置为联系人默认或者真是头像。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值