前言:
進(jìn)度條常見的樣式, 目前暫時(shí)沒看到比較好用的框架, 或者說不好在原有的基礎(chǔ)上擴(kuò)展, 本框架的成員變量和方法幾乎都是用protected 和 public, 給用戶隨便擴(kuò)展.
Github地址: https://github.com/liys666666/LProgressView
先上效果圖---常見樣式

總體效果.gif

結(jié)構(gòu)圖.png
一. 導(dǎo)入框架
//項(xiàng)目根目錄下 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

LineProView.png
//公共屬性
<attr name="progress_max" format="integer"/> //總數(shù)
<attr name="progress_value" format="integer"/> //進(jìn)度
<attr name="progress_size" format="dimension"/> //進(jìn)度條 大小
<attr name="progress_color" format="color"/> //進(jìn)度條 顏色
<attr name="progress_color_background" format="color"/> //進(jìn)度條背景顏色
<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"/> //保留多少位小數(shù)
<attr name="light_color" format="color"/> //發(fā)光顏色
<attr name="light_show" format="boolean"/> //是否需要發(fā)光
<attr name="stroke_color" format="color"/> //邊框顏色
<attr name="stroke_width" format="dimension"/> //邊框大小
<attr name="stroke_show" format="boolean"/> //是否需要邊框
<!--line進(jìn)度條特有-->
<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"/> //進(jìn)度條 前進(jìn)方向圓角
2. LineCentreProView

LineCentreProView.png
<!-- 公共屬性 -->
<attr name="progress_max" format="integer"/> //總數(shù)
<attr name="progress_value" format="integer"/> //進(jìn)度
<attr name="progress_size" format="dimension"/> //進(jìn)度條 大小
<attr name="progress_color" format="color"/> //進(jìn)度條 顏色
<attr name="progress_color_background" format="color"/> //進(jìn)度條背景顏色
<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"/> //保留多少位小數(shù)
<attr name="light_color" format="color"/> //發(fā)光顏色
<attr name="light_show" format="boolean"/> //是否需要發(fā)光
<attr name="stroke_color" format="color"/> //邊框顏色
<attr name="stroke_width" format="dimension"/> //邊框大小
<attr name="stroke_show" format="boolean"/> //是否需要邊框
<!--line進(jìn)度條特有-->
<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"/> //進(jìn)度條 前進(jìn)方向圓角
<attr name="box_width" format="dimension"/> //方框?qū)挾? <attr name="box_radius" format="dimension"/> //方框圓角
3. LineBottomProView

LineBottomProView.png
<attr name="progress_max" format="integer"/> //總數(shù)
<attr name="progress_value" format="integer"/> //進(jìn)度
<attr name="progress_size" format="dimension"/> //進(jìn)度條 大小
<attr name="progress_color" format="color"/> //進(jìn)度條 顏色
<attr name="progress_color_background" format="color"/> //進(jìn)度條背景顏色
<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"/> //保留多少位小數(shù)
<attr name="light_color" format="color"/> //發(fā)光顏色
<attr name="light_show" format="boolean"/> //是否需要發(fā)光
<!--圓角半徑-->
<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

ArcProView.png
<attr name="progress_max" format="integer"/> //總數(shù)
<attr name="progress_value" format="integer"/> //進(jìn)度
<attr name="progress_size" format="dimension"/> //進(jìn)度條 大小
<attr name="progress_color" format="color"/> //進(jìn)度條 顏色
<attr name="progress_color_background" format="color"/> //進(jìn)度條背景顏色
<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"/> //保留多少位小數(shù)
<attr name="light_color" format="color"/> //發(fā)光顏色
<attr name="light_show" format="boolean"/> //是否需要發(fā)光
<attr name="arc_start_angle" format="integer"/> //開始角度
<attr name="arc_draw_angle" format="integer"/> //需要繪制的角度
5. WaterWaveProView

WaterWaveProView.png
<attr name="progress_max" format="integer"/> //總數(shù)
<attr name="progress_value" format="integer"/> //進(jìn)度
<attr name="progress_size" format="dimension"/> //進(jìn)度條 大小
<attr name="progress_color" format="color"/> //進(jìn)度條 顏色
<attr name="progress_color_background" format="color"/> //進(jìn)度條背景顏色
<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"/> //保留多少位小數(shù)
<attr name="light_color" format="color"/> //發(fā)光顏色
<attr name="light_show" format="boolean"/> //是否需要發(fā)光
<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"/> // 水波長(zhǎng)
<attr name="water_wave_height" format="dimension"/> //水波高度
<attr name="water_wave_speed" format="integer"/> //水波--速度
三. 總結(jié)
1. 這里沒有漸變屬性, 如果需要, 可參考每個(gè)ProView對(duì)應(yīng)的詳細(xì)文章.
2. 使用簡(jiǎn)介, 學(xué)習(xí)成本低, 屬性一查即可知道
3. 支持用戶在原有的基礎(chǔ)擴(kuò)展和修改, 每個(gè)成員變量幾乎都有set和get方法.
① 例如: 對(duì)于畫筆Paint可以用對(duì)應(yīng)get方法取出, 然后設(shè)置對(duì)應(yīng)的屬性.
② 例如: 繼承對(duì)應(yīng)的View, 重寫對(duì)應(yīng)的方法進(jìn)行覆蓋.
如有問題和建議, 歡迎在評(píng)論區(qū)指出, 如果此框架對(duì)你有用, 歡迎點(diǎn)贊收藏