- 浏览: 41553 次
- 性别:
- 来自: 济南
文章分类
最新评论
三种方式实现自定义圆形进度条ProgressBar
- 博客分类:
- android-2013
一、通过动画实现
定义res/anim/loading.xml如下:
[html] view plaincopyprint?
<?xml version="1.0" encoding="UTF-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="150" android:drawable="@drawable/loading_01" />
<item android:duration="150" android:drawable="@drawable/loading_02" />
<item android:duration="150" android:drawable="@drawable/loading_03" />
<item android:duration="150" android:drawable="@drawable/loading_04" />
<item android:duration="150" android:drawable="@drawable/loading_05" />
<item android:duration="150" android:drawable="@drawable/loading_06" />
<item android:duration="150" android:drawable="@drawable/loading_07" />
</animation-list>
二、通过自定义颜色实现
定义res/drawable/progress_small.xml如下:
[html] view plaincopyprint?
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false" >
<gradient
android:centerColor="#FFFFFF"
android:centerY="0.50"
android:endColor="#1E90FF"
android:startColor="#000000"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
三、使用一张图片进行自定义
定义res/drawable/progress_small.xml如下:
[html] view plaincopyprint?
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/spinner_black_16"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="360" />
使用方法都一样, 如下:
[html] view plaincopyprint?
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/progress_small"/>
也可以根据需要通过设置style来设置其大小! 一般只有使用默认的ProgrressBar的时候采用。对于上述三种自定义的方式,建议修改直接修改图片大小,或者shape;
[html] view plaincopyprint?
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="?android:attr/progressBarStyleSmall"
android:indeterminateDrawable="@drawable/progress_small"/>
设置成progressBarStyleSmall后,图标变小。
设置成progressBarStyleLarge后,图标变大
定义res/anim/loading.xml如下:
[html] view plaincopyprint?
<?xml version="1.0" encoding="UTF-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="150" android:drawable="@drawable/loading_01" />
<item android:duration="150" android:drawable="@drawable/loading_02" />
<item android:duration="150" android:drawable="@drawable/loading_03" />
<item android:duration="150" android:drawable="@drawable/loading_04" />
<item android:duration="150" android:drawable="@drawable/loading_05" />
<item android:duration="150" android:drawable="@drawable/loading_06" />
<item android:duration="150" android:drawable="@drawable/loading_07" />
</animation-list>
二、通过自定义颜色实现
定义res/drawable/progress_small.xml如下:
[html] view plaincopyprint?
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false" >
<gradient
android:centerColor="#FFFFFF"
android:centerY="0.50"
android:endColor="#1E90FF"
android:startColor="#000000"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
三、使用一张图片进行自定义
定义res/drawable/progress_small.xml如下:
[html] view plaincopyprint?
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/spinner_black_16"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="360" />
使用方法都一样, 如下:
[html] view plaincopyprint?
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/progress_small"/>
也可以根据需要通过设置style来设置其大小! 一般只有使用默认的ProgrressBar的时候采用。对于上述三种自定义的方式,建议修改直接修改图片大小,或者shape;
[html] view plaincopyprint?
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="?android:attr/progressBarStyleSmall"
android:indeterminateDrawable="@drawable/progress_small"/>
设置成progressBarStyleSmall后,图标变小。
设置成progressBarStyleLarge后,图标变大
发表评论
-
Android下屏保程序的开发
2014-01-09 17:08 0有时候,需要在程序中实现屏保相关的功能,如指定一段时间后,显示 ... -
Android command
2013-11-06 11:20 01. Android支持的linux command不多,在/ ... -
如何一个android工程作为另外一个android工程的lib
2013-10-19 17:01 0在实际使用中,我们可能会把一个android工程作为库,然后 ... -
Android属性(property)机制
2013-09-25 14:39 24621. 属性简介 Android里有很多属性(property ... -
Android编译系统
2013-09-23 19:07 331上次翻译了官方的Android编译系统手册(http://bl ... -
1.把我调试好的NFC上层代码加入GIT服务器代码中,并创建编译开关。
2013-08-21 09:33 0之前遇到的问题:向系统发送一个长按触摸事件,再发送其他触摸事件 ... -
2013-01-10 10:47 android多国语言使用
2013-08-12 20:57 720多国语言:在res目录下建立不同名称的values文件来调用不 ... -
android中dip px sp度量单位
2013-08-06 15:24 0目前android默认的low=120 ... -
minicom的配置
2013-07-08 09:58 5051、在使用minicom之前,首先要保证你对串口有读/写的权限 ... -
Android扩展一个硬件模块
2013-06-19 13:30 0为Android扩展一个硬件模块需要做两件事: 1、硬件和内 ... -
Android修改默认浏览器为其他浏览器
2013-06-15 10:09 1281public class MainActivity exten ... -
Android::开放root权限
2013-05-31 12:59 0开放系统root权限,即使任何用户都可以执行su程序,以使得临 ... -
android 开机logo,和开机动画
2013-05-11 23:17 0一.设置LINUX内核启动LOGO 1、让内核 ... -
android 4.0读写HID装置
2013-05-03 18:31 0求解:android 4.0读写HID设备 大家好,从3.1开 ... -
JAVA 双向SSL,SOCKET客户端/服务端
2013-03-29 14:13 901JAVA 双向SSL,SOCKET客户端/服务端 实现技术: ... -
java 面向 Socket 操作,TCP 和 UDP 示例
2013-03-21 15:55 628TCP/IP 参考模型 应用层-->传输层--> ... -
Android系统Surface制的SurfaceFlinger服务的线程模型分析
2013-03-21 11:31 542在前面两篇文章中,我们分析了SurfaceFlinge ... -
C++ 代码创建虚拟机调用java方法
2013-03-21 11:28 815Java 和 C/C++代码的互相调用一般都是采用JNI的方法 ... -
android keycode 分发
2013-03-11 16:20 0******************************* ... -
android 获得当前活动的Acticity
2013-02-25 15:17 1486ActivityManager activityManager ...
相关推荐
Android 三种常用实现自定义圆形进度条 ProgressBar 博客:http://blog.csdn.net/q610098308/article/details/53760024
进度条样式在项目中经常可以见到,下面小编给大家分享Android三种方式实现...自定义圆形进度条ProgressBar的一般有三种方式: 一、通过动画实现 定义res/anim/loading_anim.xml如下: <?xml version=1.0 en
win8 小点进度条,自定义圆形进度条,wpf Progressbar进度条样式更改
自定义圆形进度条
本程序包含三个自定义的圆形进度条progressbar 程序代码比较少,主要通过XML布局实现 主要是学习自定义的圆形进度条的用法
总共分为三层:一层为圆形边线,一层为进度边线,一层用来显示标识进度节点。 public class CircleProgressBar extends View { private int maxProgress = 100; private int progress = 15; private int ...
自定义圆形ProgressBar(进度条),支持各种属性和配置。对应的文章:http://www.cnblogs.com/tianzhijiexian/p/3854346.html
多种酷炫的自定义ProgressBar的圆形加载进度条源码,带百分比进度显示
C# Winform圆形进度条(改良版)从csdn下载,增加了圆形进度值文字显示。GDI+绘制,效率高。
通过继承progressbar实现圆形进度条的倒计时
android自定义半圆进度条,可以自己根据里面备注的参数,调整半圆的长度。这里是使用说明:http://blog.csdn.net/beibaokongming/article/details/79002646
android 自定义水平与圆形进度条,有百分比显示。
这是一个圆形进度条,蓝色背景,用一个动画,一组图片来显示。自定义dialog
随着缓冲进度更新的圆形进度条,可以通过属性标签更改进度条的背景颜色和文字内容及文字颜色等。
自定义Android圆形进度条,你用系统的ProgressBar绝对实现不了这种效果。
外观漂亮的自定义圆形进度条,可以实现进度条的动态加载。
本文实例讲述了Android编程基于自定义View实现绚丽的圆形进度条功能。分享给大家供大家参考,具体如下: 本文包含两个组件,首先上效果图: 1.ProgressBarView1(支持拖动): 2.ProgressBarView2(不同进度值显示...
该demo实现利用自定义view实现的椭圆形的进度条
android自定义ProgressBar(仿淘宝)的加载效果