转载:http://www.eoeandroid.com/forum.php?mod=viewthread&tid=76872

一、通过动画实现

定义res/anim/loading.xml如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <animation-list android:oneshot="false"
  3. xmlns:android="http://schemas.android.com/apk/res/android">
  4. <item android:duration="150" android:drawable="@drawable/loading_01" />
  5. <item android:duration="150" android:drawable="@drawable/loading_02" />
  6. <item android:duration="150" android:drawable="@drawable/loading_03" />
  7. <item android:duration="150" android:drawable="@drawable/loading_04" />
  8. <item android:duration="150" android:drawable="@drawable/loading_05" />
  9. <item android:duration="150" android:drawable="@drawable/loading_06" />
  10. <item android:duration="150" android:drawable="@drawable/loading_07" />
  11. </animation-list>

在layout文件中引用如下:

  1. <ProgressBar android:id="@+id/loading_process_dialog_progressBar"
  2. android:layout_width="wrap_content" android:layout_height="wrap_content"
  3. android:indeterminate="false" android:indeterminateDrawable="@anim/loading" />

二、通过自定义颜色实现
定义res/drawable/dialog_style_xml_color.xml如下:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <rotate xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
  4. android:toDegrees="360">
  5. <shape android:shape="ring" android:innerRadiusRatio="3"
  6. android:thicknessRatio="8" android:useLevel="false">
  7. <gradient android:type="sweep" android:useLevel="false"
  8. android:startColor="#FFFFFF" android:centerColor="#FFDC35"
  9. android:centerY="0.50" android:endColor="#CE0000" />
  10. </shape>
  11. </rotate>

在layout文件中引用如下:

  1. <ProgressBar android:id="@+id/loading_process_dialog_progressBar"
  2. android:layout_width="wrap_content" android:layout_height="wrap_content"
  3. android:indeterminate="false" android:indeterminateDrawable="@drawable/dialog_style_xml_color" />

三、使用一张图片进行自定义
定义res/drawable/dialog_style_xml_icon.xml如下:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  3. <item>
  4. <rotate android:drawable="@drawable/dialog_progress_round"
  5. android:fromDegrees="0.0" android:toDegrees="360.0" android:pivotX="50.0%"
  6. android:pivotY="50.0%" />
  7. </item>
  8. </layer-list>

在layout文件中引用如下:

  1. <ProgressBar android:id="@+id/loading_process_dialog_progressBar"
  2. android:layout_width="wrap_content" android:layout_height="wrap_content"
  3. android:indeterminate="false" android:indeterminateDrawable="@drawable/dialog_style_xml_icon" />

main.xml如下:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical" android:layout_width="fill_parent"
  4. android:layout_height="fill_parent" android:gravity="center"
  5. android:background="#FFF">
  6. <Button android:text="@string/anim" android:id="@+id/anim"
  7. android:layout_width="120dip" android:layout_height="wrap_content" />
  8. <Button android:text="@string/color" android:id="@+id/color"
  9. android:layout_width="120dip" android:layout_height="wrap_content" />
  10. <Button android:text="@string/icon" android:id="@+id/icon"
  11. android:layout_width="120dip" android:layout_height="wrap_content" />
  12. </LinearLayout>

之后通过三个按钮将ProgressBar 放在对话框中显示出来就完成了。

 AnimRoundProcessDialog.rar

截图如下:

Android 三种方式实现自定义圆形页面加载中效果的进度条的更多相关文章

  1. Android 三种方式实现自定义圆形进度条ProgressBar

    一.通过动画实现 定义res/anim/loading.xml如下: <?xml version="1.0" encoding="UTF-8"?> ...

  2. 三种方式解决你的js加载乱码

    第一种方式——编码统一 我们以前觉得出现乱码的原因是因为编码不统一,就是因为我们设置编码统一之后,就解决了问题,所以,让html和js的编码统一,是最简单的一个乱码解决方式,原因是什么,是因为,如果你 ...

  3. 【Android进度条】三种方式实现自定义圆形进度条ProgressBar

    一.通过动画实现 定义res/anim/loading.xml如下: <?xml version="1.0" encoding="UTF-8"?> ...

  4. jQuery8种不同的瀑布流懒加载loading效果

    优化图片加载插件jQuery8种不同的瀑布流懒加载loading效果  在线预览 下载地址 实例代码 <ul class="grid effect-1" id="g ...

  5. css 实现页面加载中等待效果

    <!DOCTYPE html> <html> <head> <title>css实现页面加载中,请稍候效果</title> <meta ...

  6. 利用document的readyState去实现页面加载中的效果

    打开新的网页时,为了增强友好性体验,告知用户网页正在加载数据需要呈现一个"页面加载中"之类的提示,只需要利用document就可以实现. 实现示例代码如下: <style&g ...

  7. 页面加载中jquery逐渐消失效果实现

    为了获得更好的用户体验,现在大多数网页都会在页面中加一个加载中效果,这里实现一个加载中逐渐消失的效果,以至于看上去不那么生硬. html: <div id="loading" ...

  8. 三种思路实现自定义404页面:Tomcat、SpringMVC精准匹配、重写DispatchServlet

    第1种方式:Tomcat直接处理 web.xml <error-page> <error-code>404</error-code> <location> ...

  9. 三种方式创建bean对象在springIOC容器中初始化、销毁阶段要调用的自定义方法

    1. 使用@Bean注解定义initMethod和destroyMethod 所谓initMethod和destroyMethod,是指在springIOC容器中,对于bean对象执行到初始化阶段和销 ...

随机推荐

  1. yii2归档安装

    1.http://www.yiiframework.com/download/ 下载文件 2.如果inint.bat文件一闪而过,没有提示是开发还是生产环境 用编辑器(phpstorm)打开文件在对应 ...

  2. Error Handling and Exception

    The default error handling in PHP is very simple.An error message with filename, line number and a m ...

  3. Bootstrap全局css

    HTML中的所有标题标签,<h1>到<h6>均可使用.另外,还提供了.h1到.h6类,为的是给内联(inline)属性的文本赋予标题的样式.在标题内还可以包含<small ...

  4. hdu1166敌兵布阵_线段树单点更新

    Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任 ...

  5. CODEVS1380 没有上司的舞会 (树形DP)

    f[i,0] 表示 第i个人不参加舞会 f[i,1] 表示 第i个人参加舞会 f[i,1]=sigma(f[j,0])+v[i]   j 为 i 的孩子 f[i,1]=sigma(max(f[j,0] ...

  6. HDU 1080

    http://acm.hdu.edu.cn/showproblem.php?pid=1080 二维最长公共子序列 #include <iostream> #include <cstd ...

  7. 转:Bat命令学习

    转:http://www.cnblogs.com/SunShineYPH/archive/2011/12/13/2285570.html一.基础语法: 1.批处理文件是一个“.bat”结尾的文本文件, ...

  8. source insight 注册码

    分享一下google来的 呵呵 Source Insight,一个无比强大的工具.一个很好的查看代码的工具.到它的官网上去看一下,就知道,世界上基本上所有的大的软件公司,都在用这个工具.习惯了这个工具 ...

  9. yii表单

    yii  的dropdownlist,用yii的session可以记下选中的状态 $form = $this->beginWidget('CActiveForm',array('action'= ...

  10. editplus 常用快捷键汇总 大小写代码折叠

    文本类 新建普通文本:Ctrl+N新建浏览器窗口:Ctrl+Shift+B新建HTML页:Ctrl+Shift+N打开:Ctrl+O打开一个现有的文档文件结尾:Ctrl+End选区扩展到文档结尾处:C ...