ProgressWheel

progresswheel是github上面的一个开源的项目
这个是一个圆形进度条

这个也是利用github上面提供的源代码


现在开始介绍如何使用progresswheel是怎样使用的
第一步:
首先,我们需要在别人的github上面下载源代码
然后把源代码取出来
取得是 ProgressWheel这个自定义控件的源代码
把progresswheel这个源码复制到自己的工程目录底下


第二步:
下面要讲progresswheel得属性加到工程底下
在value目录底下新建一个attrs.xml文件
然后把下面的属性值添加上去
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <declare-styleable name="ProgressWheel">
  <attr name="text" format="string" />
  <attr name="textColor" format="color" />
  <attr name="textSize" format="dimension" />
  <attr name="barColor" format="color" /><!-- 进度条颜色 -->
  <attr name="rimColor" format="color" /><!-- 默认轮廓颜色 -->
  <attr name="rimWidth" format="dimension" />
  <attr name="spinSpeed" format="dimension" />
  <attr name="delayMillis" format="integer" />
  <attr name="circleColor" format="color" /><!-- 圆圈内部的颜色 -->
  <attr name="radius" format="dimension" />
  <attr name="barWidth" format="dimension" /><!-- 进度条宽度 -->
  <attr name="barLength" format="dimension" /><!-- 进度条长度(即进度条走过的长度) -->
  <attr name="contourColor" format="color"/><!-- 控制外边缘颜色 -->
  <attr name="contourSize" format="dimension"/>
    </declare-styleable>   
</resources>
第三步:
在布局文件上面加上命名空间,加上这个的原因是下面的控件要用到特定的属性值,所以要通过这个路径去找到,
xmlns:ProgressWheel="http://schemas.android.com/apk/res/包名"
上面的方式是参考网上的,但是会出错,但是我把路径改为下面这个的时候就正确了
xmlns:ProgressWheel="http://schemas.android.com/apk/res-auto"

第四步:
声明控件
在布局文件下面,我们要声明控件,所以要调用了之前的自定义的控件
然后在加上自定义控件的一些属性
<com.example.view.ProgressWheel
  android:id="@+id/pw_spinner"
  android:layout_width="180dp"
  android:layout_height="180dp"
  android:layout_centerInParent="true"
  ProgressWheel:barColor="#0097D6"
  ProgressWheel:barLength="160dp"
  ProgressWheel:barWidth="15dp"
  ProgressWheel:rimColor="#330097D6"
  ProgressWheel:rimWidth="15dp"
  ProgressWheel:text="wait..."
  ProgressWheel:contourColor="#330097D6"
  ProgressWheel:textColor="#222"

第五步:
最后我们就可以在代码中使用控件
wheel = (ProgressWheel) findViewById(R.id.pw_spinner);//找到控件
    wheel.setProgress(180);//设置进度
    wheel.incrementProgress();//增加进度
    wheel.spin();//使控件开始旋转
    wheel.stopSpinning();//停止旋转

这样我们就完成了progresswheel的使用
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wyu-jat

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值