Android

Android 常见进度条---合集 LProgressView

2021-07-05  本文已影响0人  因为我的心

一、前言:

进度条常见的样式, 目前暂时没看到比较好用的框架, 或者说不好在原有的基础上扩展, 本框架的成员变量和方法几乎都是用protected 和 public, 给用户随便扩展.

Github地址: https://github.com/liys666666/LProgressView
先上效果图---常见样式
aaa.gif 图片.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
图片.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
图片.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
图片.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
图片.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
图片.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"/> //水波--速度

四、 总结

  1. 这里没有渐变属性, 如果需要, 可参考每个ProView对应的详细文章.
  2. 使用简介, 学习成本低, 属性一查即可知道
  3. 支持用户在原有的基础扩展和修改, 每个成员变量几乎都有set和get方法.
    ① 例如: 对于画笔Paint可以用对应get方法取出, 然后设置对应的属性.
    ② 例如: 继承对应的View, 重写对应的方法进行覆盖.

链接:https://www.jianshu.com/p/cd9d85a2a01a
其它优秀地址:
地址1:https://github.com/skydoves/ProgressView
地址2:https://github.com/Moosphan/Material-ProgressView

上一篇下一篇

猜你喜欢

热点阅读