你好,游客 登录 注册 搜索
背景:
阅读新闻

ProgressWheel:Android开源圆环进度条

[日期:2014-12-13] 来源:Linux社区  作者:Linux [字体:大 中 小]

这是一个自定义Android组件,用于代替标准进度条组件。实现各种进度条样式,包括圆环,扫描等。

XML:

在你的attr.xml(res/value)中加入以下

<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 中加入

xmlns:ProgressWheel="http://schemas.android.com/apk/res/com.visualdenim.schooltraq"

在你的xml合适的地方加入 组件

<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"/>

你需要从layout中获得进度条,或者初始化

ProgressWheel pw = newProgressWheel(myContext, myAttributes);
ProgressWheel pw = (ProgressWheel) findViewById(R.id.pw_spinner);

使用.spin() 开始进度条滚动, .stopSpinning 停止进度条滚动

增加进度有点棘手,  你可以调用.incrementProgress(), 但是这样就超过了360度, 因为一个圆有360度, 你超过360度就会自动重置, 一个百分百自动分配。

更多Android相关信息见Android 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=11

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-12/110447.htm

linux
相关资讯       Android组件  ProgressWheel 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款