一、通过动画实现

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

View Row Code
<?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如下:

View Row Code
<?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如下:

View Row Code
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/progress_small"/>

使用方法都一样, 如下:

View Row Code
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/progress_small"/>

也可以根据需要通过设置style来设置其大小! 一般只有使用默认的ProgrressBar的时候采用。对于上述三种自定义的方式,建议修改直接修改图片大小,或者shape;

View Row Code
<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三种实现自定义ProgressBar的方式介绍的更多相关文章

  1. Hive中的三种不同的数据导出方式介绍

    问题导读:1.导出本地文件系统和hdfs文件系统区别是什么?2.带有local命令是指导出本地还是hdfs文件系统?3.hive中,使用的insert与传统数据库insert的区别是什么?4.导出数据 ...

  2. 014-HQL中级4-Hive中的三种不同的数据导出方式介绍

    根据导出的地方不一样,将这些方式分为三种:(1).导出到本地文件系统:(2).导出到HDFS中:(3).导出到Hive的另一个表中.为了避免单纯的文字,我将一步一步地用命令进行说明. 一.导出到本地文 ...

  3. Android中三种超实用的滑屏方式汇总(转载)

    Android中三种超实用的滑屏方式汇总   现如今主流的Android应用中,都少不了左右滑动滚屏这项功能,(貌似现在好多人使用智能机都习惯性的有事没事的左右滑屏,也不知道在干什么...嘿嘿),由于 ...

  4. Android三种基本的加载网络图片方式(转)

    Android三种基本的加载网络图片方式,包括普通加载网络方式.用ImageLoader加载图片.用Volley加载图片. 1. [代码]普通加载网络方式 ? 1 2 3 4 5 6 7 8 9 10 ...

  5. 6_1 持久化模型与再次加载_探讨(1)_三种持久化模型加载方式以及import_meta_graph方式加载持久化模型会存在的变量管理命名混淆的问题

    笔者提交到gitHub上的问题描述地址是:https://github.com/tensorflow/tensorflow/issues/20140 三种持久化模型加载方式的一个小结论 加载持久化模型 ...

  6. ASP.NET Core应用的错误处理[1]:三种呈现错误页面的方式

    由于ASP.NET Core应用是一个同时处理多个请求的服务器应用,所以在处理某个请求过程中抛出的异常并不会导致整个应用的终止.出于安全方面的考量,为了避免敏感信息的外泄,客户端在默认的情况下并不会得 ...

  7. Js之Dom学习-三种获取页面元素的方式、事件、innerText和innerHTML的异同

    一.三种获取页面元素的方式: getElementById:通过id来获取 <body> <input type="text" value="请输入一个 ...

  8. Android三种左右滑动效果 手势识别

    Android三种左右滑动效果 手势识别(转)   手势识别 1.onCreate中添加GestureDetector mGestureDetector; //监听手势事件 mGestureDetec ...

  9. .NET提供了三种后台输出js的方式:

    .NET提供了三种后台输出js的方式: 首先创建 js文件testjs.js {    Page.ClientScript.RegisterClientScriptInclude("keys ...

随机推荐

  1. [HOWTO] Install Sphinx for A Script Pro

    Hi, Here's a small howto on installing Sphinx Search (http://sphinxsearch.com/) and configuring it t ...

  2. Android RecyclerView Adapter 新式用法之SortedListAdapterCallback

    引言 前几天在同事的提醒下发现V7中有了一个新的工具类SortedListAdapterCallback,配合RecyclerView Adapter和SortedList一起使用更加方便的管理我们在 ...

  3. G - A+B for Input-Output Practice (VI)

      Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description You ...

  4. uboot移植参考资料

    参考文档:移植u-boot-1.1.6到TQ2440文档.pdf 参考网页:uboot在S3C2440上移植<出自超哥(相广超)>

  5. java项目导出jar文件时指定main方法的类

    需要先运行一下main函数,eclipse的Export-->Runnable JAR File ---> 下的Launch configuration下拉列表才会有记录.如果想要删除下拉 ...

  6. 如何使用SplitContainer控件[转]

    原文地址:http://yinzhihua2008.blog.163.com/blog/static/794306720120511150457/ 在Windows资源管理器中,当把鼠标指针移动到Tr ...

  7. C# DataGridView 导出 Excel(根据Excel版本显示选择不同后缀格式xls或xlsx)

    /// <summary> /// DataGridView导出至Excel,解决问题:打开Excel文件格式与扩展名指定格式不一致 /// </summary> /// &l ...

  8. Android Wear开发 - 数据通讯 - 第三节 : 事件处理

    http://developer.android.com/training/wearables/data-layer/events.html 以下是本人在学习官方开发文档时的笔记,主要是翻译为主,并在 ...

  9. Linux Shell编程(9)——特殊变量类型

    局部变量局部变量只在代码块或一个函数里有效 (参考函数里的局部变量)环境变量这种变量会影响Shell的行为和用户接口 在大多数情况下,每个进程都会有一个"环境表", 它由一组由进程 ...

  10. HDU 5873 Football Games 【模拟】 (2016 ACM/ICPC Asia Regional Dalian Online)

    Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...