一、前言:
进度条常见的样式, 目前暂时没看到比较好用的框架, 或者说不好在原有的基础上扩展, 本框架的成员变量和方法几乎都是用protected 和 public, 给用户随便扩展.
Github地址: https://github.com/liys666666/LProgressView
先上效果图---常见样式
![](https://img.haomeiwen.com/i11268516/74fc0833abc3a430.gif)
![](https://img.haomeiwen.com/i11268516/03080806be6d3dfa.png)
二、导入框架
//项目根目录下 build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' } //添加
}
}
//app目录下 build.gradle
dependencies {
implementation 'com.github.liys666666:LProgressView:V1.0.82' //添加
}
//xml布局中
<com.liys.view.LineProView
....
app:progress_value = "50"/>
<com.liys.view.LineCentreProView
.... />
<com.liys.view.LineBottomProView
.... />
<com.liys.view.ArcProView
.... />
<com.liys.view.WaterWaveProView
.... />
三、 所有属性
1. LineProView
![](https://img.haomeiwen.com/i11268516/1e61b9c57fb44196.png)
//公共属性
<attr name="progress_max" format="integer"/> //总数
<attr name="progress_value" format="integer"/> //进度
<attr name="progress_size" format="dimension"/> //进度条 大小
<attr name="progress_color" format="color"/> //进度条 颜色
<attr name="progress_color_background" format="color"/> //进度条背景颜色
<attr name="text_size" format="dimension"/> //文字大小
<attr name="text_color" format="color"/> //文字颜色
<attr name="text_show" format="boolean"/> //是否显示文字
<attr name="text_decimal_num" format="integer"/> //保留多少位小数
<attr name="light_color" format="color"/> //发光颜色
<attr name="light_show" format="boolean"/> //是否需要发光
<attr name="stroke_color" format="color"/> //边框颜色
<attr name="stroke_width" format="dimension"/> //边框大小
<attr name="stroke_show" format="boolean"/> //是否需要边框
<!--line进度条特有-->
<attr name="radius" format="dimension"/> //圆角
<attr name="left_top_radius" format="dimension"/>
<attr name="left_bottom_radius" format="dimension"/>
<attr name="right_top_radius" format="dimension"/>
<attr name="right_bottom_radius" format="dimension"/>
<attr name="progress_radius" format="dimension"/> //进度条 前进方向圆角
2. LineCentreProView
![](https://img.haomeiwen.com/i11268516/fc2fa89825d065b6.png)
<!-- 公共属性 -->
<attr name="progress_max" format="integer"/> //总数
<attr name="progress_value" format="integer"/> //进度
<attr name="progress_size" format="dimension"/> //进度条 大小
<attr name="progress_color" format="color"/> //进度条 颜色
<attr name="progress_color_background" format="color"/> //进度条背景颜色
<attr name="text_size" format="dimension"/> //文字大小
<attr name="text_color" format="color"/> //文字颜色
<attr name="text_show" format="boolean"/> //是否显示文字
<attr name="text_decimal_num" format="integer"/> //保留多少位小数
<attr name="light_color" format="color"/> //发光颜色
<attr name="light_show" format="boolean"/> //是否需要发光
<attr name="stroke_color" format="color"/> //边框颜色
<attr name="stroke_width" format="dimension"/> //边框大小
<attr name="stroke_show" format="boolean"/> //是否需要边框
<!--line进度条特有-->
<attr name="radius" format="dimension"/>
<attr name="left_top_radius" format="dimension"/>
<attr name="left_bottom_radius" format="dimension"/>
<attr name="right_top_radius" format="dimension"/>
<attr name="right_bottom_radius" format="dimension"/>
<attr name="progress_radius" format="dimension"/> //进度条 前进方向圆角
<attr name="box_width" format="dimension"/> //方框宽度
<attr name="box_radius" format="dimension"/> //方框圆角
3. LineBottomProView
![](https://img.haomeiwen.com/i11268516/8c5dfadbae2ac2e7.png)
<attr name="progress_max" format="integer"/> //总数
<attr name="progress_value" format="integer"/> //进度
<attr name="progress_size" format="dimension"/> //进度条 大小
<attr name="progress_color" format="color"/> //进度条 颜色
<attr name="progress_color_background" format="color"/> //进度条背景颜色
<attr name="text_size" format="dimension"/> //文字大小
<attr name="text_color" format="color"/> //文字颜色
<attr name="text_show" format="boolean"/> //是否显示文字
<attr name="text_decimal_num" format="integer"/> //保留多少位小数
<attr name="light_color" format="color"/> //发光颜色
<attr name="light_show" format="boolean"/> //是否需要发光
<!--圆角半径-->
<attr name="radius" format="dimension"/> //圆角
<attr name="box_width" format="dimension"/> //方框--宽度
<attr name="box_height" format="dimension"/> //方框--高度
<attr name="box_radius" format="dimension"/> //方框--圆角
4. ArcProView
![](https://img.haomeiwen.com/i11268516/3d91cc23c227c577.png)
<attr name="progress_max" format="integer"/> //总数
<attr name="progress_value" format="integer"/> //进度
<attr name="progress_size" format="dimension"/> //进度条 大小
<attr name="progress_color" format="color"/> //进度条 颜色
<attr name="progress_color_background" format="color"/> //进度条背景颜色
<attr name="text_size" format="dimension"/> //文字大小
<attr name="text_color" format="color"/> //文字颜色
<attr name="text_show" format="boolean"/> //是否显示文字
<attr name="text_decimal_num" format="integer"/> //保留多少位小数
<attr name="light_color" format="color"/> //发光颜色
<attr name="light_show" format="boolean"/> //是否需要发光
<attr name="arc_start_angle" format="integer"/> //开始角度
<attr name="arc_draw_angle" format="integer"/> //需要绘制的角度
5. WaterWaveProView
![](https://img.haomeiwen.com/i11268516/606e4710b35c4360.png)
<attr name="progress_max" format="integer"/> //总数
<attr name="progress_value" format="integer"/> //进度
<attr name="progress_size" format="dimension"/> //进度条 大小
<attr name="progress_color" format="color"/> //进度条 颜色
<attr name="progress_color_background" format="color"/> //进度条背景颜色
<attr name="text_size" format="dimension"/> //文字大小
<attr name="text_color" format="color"/> //文字颜色
<attr name="text_show" format="boolean"/> //是否显示文字
<attr name="text_decimal_num" format="integer"/> //保留多少位小数
<attr name="light_color" format="color"/> //发光颜色
<attr name="light_show" format="boolean"/> //是否需要发光
<attr name="stroke_color" format="color"/> //边框颜色
<attr name="stroke_width" format="dimension"/> //边框大小
<attr name="stroke_show" format="boolean"/> //是否需要边框
<attr name="water_wave_width" format="dimension"/> // 水波长
<attr name="water_wave_height" format="dimension"/> //水波高度
<attr name="water_wave_speed" format="integer"/> //水波--速度
四、 总结
- 这里没有渐变属性, 如果需要, 可参考每个ProView对应的详细文章.
- 使用简介, 学习成本低, 属性一查即可知道
- 支持用户在原有的基础扩展和修改, 每个成员变量几乎都有set和get方法.
① 例如: 对于画笔Paint可以用对应get方法取出, 然后设置对应的属性.
② 例如: 继承对应的View, 重写对应的方法进行覆盖.
链接:https://www.jianshu.com/p/cd9d85a2a01a
其它优秀地址:
地址1:https://github.com/skydoves/ProgressView
地址2:https://github.com/Moosphan/Material-ProgressView
网友评论