DashedCircularProgress和圆形头一样都是自定义控件;
首先声明这个自定义控件是从github上找的;从上面下载下来之后运行环境是as,我用的是eclipse;
类库导过来也没办法用。最后直接一点一点复制过来了;
其实这个自定义控件不难;我们只需要知道他的几个参数即可;
DashedCircularProgress可以随意设置宽高,这个根据大家需求自己设置;包括图标,进度条颜色都是自己随意设置的;
首先是布局文件:
<!-- 进度条最大值:custom:max="100"
进度条最小值:custom:min="0"
动画持续时间:custom:duration="1000"
外部环的颜色:custom:external_color=""
进度条图标:custom:progress_icon=""
内圈(显示进度的)圆环颜色:base_color
内圈已完成部分的圆环颜色:progress_color -->
<com.github.glomadrian.dashedcircularprogress.DashedCircularProgress
android:id="@+id/simple"
android:layout_width="300dp"
android:layout_height="310dp"
android:layout_centerInParent="true"
custom:base_color="#6effffff"
custom:duration="2000"
custom:external_color="#1affffff"
custom:max="100"
custom:min="0"
custom:progress_color="#ffffff"
custom:progress_icon="@drawable/ic_launcher" >
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="100"
android:textSize="25sp" />
</com.github.glomadrian.dashedcircularprogress.DashedCircularProgress>
activity代码:
DashedCircularProgress progress = (DashedCircularProgress)this.findViewById(R.id.simple);
TextView text = (TextView)this.findViewById(R.id.text);
progress.setOnValueChangeListener(
new DashedCircularProgress.OnValueChangeListener() {
@Override
public void onValueChange(float value) {
text.setText((int) value + "%");
}
});
progress.setValue(88);
简单的几行代码就可以搞定;主要是类库的导入,我这边已经导入好了,下面是源码,大家用的话可以直接复制;
源码下载地址:
http://download.youkuaiyun.com/detail/zheng_jiao/9506691