转载: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. iOS 从相机或相册获取图片并裁剪

    今天遇到一个用户头像上传的问题,需要从相册或者相机中读取图片.代码很简单,抽取关键部分,如下: //load user image - (void)UesrImageClicked { UIActio ...

  2. Excel文件的导出操作

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  3. BZOJ2661 连连看 (费用流)

    把所有点拆成两个,将符合条件的两个点x,y连上边,流量为1,费用为-(x+y). 做一遍最小费用最大流,最后ans div 2即可. Program bzoj2661; ; ..] of longin ...

  4. NGUI悬浮菜单思路实践

    使用NGUI制作悬浮菜单.在UIAnchor锚点下的Offset建立背景和按钮菜单.同过InputMouseXY的位置判断.是否应该弹出和收回.OffSet在此处是作为TweenGameObject的 ...

  5. 设置dt height 保证dd在同一行

    <html>   <head>   <meta charset="UTF-8">   <meta name="Author&qu ...

  6. 查看linux版本时32位的还是64位的

    一. [root@wuy2 etc]# getconf LONG_BIT [root@wuy2 etc]# getconf WORD_BIT (32位的系统中int类型和long类型一般都是4字节,6 ...

  7. Magento的价格去掉小数点

    Magento的默认情况,价格后面是有小数点的,我们来看下如何正确的来去掉小数点. 1.复制如下路径的文件 app/code/core/Mage/Directory/Model/Currency.ph ...

  8. 通知(Notification) 、 应用间通信(一)

    1 使用通知中心发送消息 1.1 问题 当一个对象需要向多个接受者发送消息的,或者不用知道消息的接收者是谁,就可以使用IOS提供的NSNotificationCenter通知中心,本案例使NSNoti ...

  9. 简单的IOS6和IOS7通过图片名适配

    在美工提供图片图片的前提下,只需要下面给UIImage做一个分类,就可以简单的实现在6和7上的图片名字适配. 比如美工在6上面提供的图片叫common_button_big_red_highlight ...

  10. Codeforces Round #298 (Div. 2) B. Covered Path

    题目大意: 一辆车,每秒内的速度恒定...第I秒到第I+1秒的速度变化不超过D.初始速度为V1,末速度为V2,经过时间t,问最远能走多远. 分析 开始的时候想麻烦了.讨论了各种情况.后来发现每个时刻的 ...