开源项目android-process-button使用和源码分析

android-process-button,扁平化带进度显示的按钮,来自Google的开发专家dmytrodanylyk的作品。显示效果如图所示。项目地址:https://github.com/dmytrodanylyk/android-process-button其中包含项目源码和Demo。一、项目使用(1).项目的引用dependencies {
摘要由CSDN通过智能技术生成
android-process-button,扁平化带进度显示的按钮,来自Google的开发专家dmytrodanylyk的作品。

显示效果如图所示。


项目地址:
https://github.com/dmytrodanylyk/android-process-button

其中包含项目源码和Demo。

一、项目使用

(1).项目的引用

dependencies {
    compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.0'
}
(2).自定义属性的介绍

<resources>
    <declare-styleable name="ProcessButton">
        <!-- “加载中”显示的文字 -->
        <attr name="pb_textProgress" format="string" />
        <!-- “加载完成”显示的文字 -->
        <attr name="pb_textComplete" format="string" />
        <!-- “加载出错”显示的文字 -->
        <attr name="pb_textError" format="string" />
        <!-- “加载中”进度条背景 -->
        <attr name="pb_colorProgress" format="color" />
        <!-- “加载完成”进度条背景 -->
        <attr name="pb_colorComplete" format="color" />
        <!-- “加载出错”进度条背景 -->
        <attr name="pb_colorError" format="color" />
    </declare-styleable>

    <declare-styleable name="FlatButton">
        <!-- 按钮按下后的背景色 -->
        <attr name="pb_colorPressed" format="color" />
        <!-- 按钮默认的背景色 -->
        <attr name="pb_colorNormal" format="color" />
        <!-- 按钮的圆角半径 -->
        <attr name="pb_cornerRadius" format="dimension" />
    </declare-styleable>
</resources>

二、源码分析
(1).类的概要
1. FlatButton,继承自Button。处理按钮的基本样式,包括背景,圆角和文字。
2. ProcessButton,继承自FlatButton。处理进度相关的显示,包括进度条样式、与进度相关的文字,并提供drawProgress()抽象方法由子类去实现。
3.剩下的三个类, ActionProcessButtonSubmitProcessButtonGenerateProcessButton,都继承自ProcessButton。各自实现了drawProgress()方法,绘制不同样式的进度条。

类的继承图:

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值