摘要:本文将带你了解Android编程之ProgressWheel:Android开源圆环进度条,希望本文对大家学Android有所帮助
这是一个自定义Android组件,用于代替标准进度条组件。实现各种进度条样式,包括圆环,扫描等。
XML:
在你的attr.xml(res/value)中加入以下
Java
<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="integer" />
<attr name="circleColor" format="color" />
<attr name="radius" format="dimension" />
<attr name="barWidth" format="dimension" />
<attr name="barLength" format="dimension" />
<attr name="delayMillis" format="dimension"/>
<attr name="contourColor" format="color"/>
<attr name="contourSize" format="float"/>
</declare-styleable>
12345678910111213141516
<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="integer" /> <attr name="circleColor" format="color" /> <attr name="radius" format="dimension" /> <attr name="barWidth" format="dimension" /> <attr name="barLength" format="dimension" /> <attr name="delayMillis" format="dimension"/> <attr name="contourColor" format="color"/> <attr name="contourSize" format="float"/></declare-styleable>
在你的root view 中加入
Java
xmlns:ProgressWheel="//schemas.android.com/apk/res/com.visualdenim.schooltraq"
1
xmlns:ProgressWheel="//schemas.android.com/apk/res/com.visualdenim.schooltraq"
Java
在你的xml合适的地方加入 组件
1
在你的xml合适的地方加入 组件
Java
<com.todddavies.components.progressbar.ProgressWheel
android:id="@+id/pw_spinner"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
ProgressWheel:text="Authenticating..."
ProgressWheel:textColor="#222"
ProgressWheel:textSize="14sp"
ProgressWheel:rimColor="#330097D6"
ProgressWheel:barLength="60dp"
ProgressWheel:barColor="#0097D6"
ProgressWheel:barWidth="5dp"
ProgressWheel:rimWidth="2dp" />
<com.todddavies.components.progressbar.ProgressWheel android:id="@+id/pw_spinner" android:layout_width="200dp" android:layout_height="200dp" android:layout_centerInParent="true" ProgressWheel:text="Authenticating..." ProgressWheel:textColor="#222" ProgressWheel:textSize="14sp" ProgressWheel:rimColor="#330097D6" ProgressWheel:barLength="60dp" ProgressWheel:barColor="#0097D6" ProgressWheel:barWidth="5dp" ProgressWheel:rimWidth="2dp" />
Java:
你需要从layout中获得进度条,或者初始化
Java
ProgressWheel pw = new ProgressWheel(myContext, myAttributes);
ProgressWheel pw = (ProgressWheel) findViewById(R.id.pw_spinner);
12
ProgressWheel pw = new ProgressWheel(myContext, myAttributes);ProgressWheel pw = (ProgressWheel) findViewById(R.id.pw_spinner);
使用.spin() 开始进度条滚动, .stopSpinning 停止进度条滚动
增加进度有点棘手, 你可以调用.incrementProgress(), 但是这样就超过了360度, 因为一个圆有360度, 你超过360度就会自动重置, 一个百分百自动分配
开源地址:https://github.com/Todd-Davies/ProgressWheel
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之Android频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号