【转】loading 三种实现方式
转载:http://www.eoeandroid.com/forum.php?mod=viewthread&tid=76872
一、通过动画实现
定义res/anim/loading.xml如下:
- <?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>
在layout文件中引用如下:
- <ProgressBar android:id="@+id/loading_process_dialog_progressBar"
- android:layout_width="wrap_content" android:layout_height="wrap_content"
- android:indeterminate="false" android:indeterminateDrawable="@anim/loading" />
二、通过自定义颜色实现
定义res/drawable/dialog_style_xml_color.xml如下:
- <?xml version="1.0" encoding="utf-8"?>
- <rotate xmlns:android="http://schemas.android.com/apk/res/android"
- android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
- android:toDegrees="360">
- <shape android:shape="ring" android:innerRadiusRatio="3"
- android:thicknessRatio="8" android:useLevel="false">
- <gradient android:type="sweep" android:useLevel="false"
- android:startColor="#FFFFFF" android:centerColor="#FFDC35"
- android:centerY="0.50" android:endColor="#CE0000" />
- </shape>
- </rotate>
在layout文件中引用如下:
- <ProgressBar android:id="@+id/loading_process_dialog_progressBar"
- android:layout_width="wrap_content" android:layout_height="wrap_content"
- android:indeterminate="false" android:indeterminateDrawable="@drawable/dialog_style_xml_color" />
三、使用一张图片进行自定义
定义res/drawable/dialog_style_xml_icon.xml如下:
- <?xml version="1.0" encoding="utf-8"?>
- <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <rotate android:drawable="@drawable/dialog_progress_round"
- android:fromDegrees="0.0" android:toDegrees="360.0" android:pivotX="50.0%"
- android:pivotY="50.0%" />
- </item>
- </layer-list>
在layout文件中引用如下:
- <ProgressBar android:id="@+id/loading_process_dialog_progressBar"
- android:layout_width="wrap_content" android:layout_height="wrap_content"
- android:indeterminate="false" android:indeterminateDrawable="@drawable/dialog_style_xml_icon" />
main.xml如下:
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="fill_parent" android:gravity="center"
- android:background="#FFF">
- <Button android:text="@string/anim" android:id="@+id/anim"
- android:layout_width="120dip" android:layout_height="wrap_content" />
- <Button android:text="@string/color" android:id="@+id/color"
- android:layout_width="120dip" android:layout_height="wrap_content" />
- <Button android:text="@string/icon" android:id="@+id/icon"
- android:layout_width="120dip" android:layout_height="wrap_content" />
- </LinearLayout>
之后通过三个按钮将ProgressBar 放在对话框中显示出来就完成了。
截图如下:


【转】loading 三种实现方式的更多相关文章
- grub安装的 三种安装方式
1. 引言 grub是什么?最常态的理解,grub是一个bootloader或者是一个bootmanager,通过grub可以引导种类丰富的系统,如linux.freebsd.windows等.但一旦 ...
- 延迟加载(Lazyload)三种实现方式
定义:延迟加载也称为惰性加载,即在长网页中延迟加载图像.用户滚动到它们之前,视口外的图像不会加载.这与图像预加载相反,在长网页上使用延迟加载将使网页加载更快.在某些情况下,它还可以帮助减少服务器负载. ...
- 通过三个DEMO学会SignalR的三种实现方式
一.理解SignalR ASP .NET SignalR 是一个ASP .NET 下的类库,可以在ASP .NET 的Web项目中实现实时通信(即:客户端(Web页面)和服务器端可以互相实时的通知消息 ...
- Hive metastore三种配置方式
http://blog.csdn.net/reesun/article/details/8556078 Hive的meta数据支持以下三种存储方式,其中两种属于本地存储,一种为远端存储.远端存储比较适 ...
- django 模板语法和三种返回方式
模板 for循环 {% for athlete in athlete_list %} <li>{{ athlete.name }}</li> {% endfor %} if语句 ...
- js的三种继承方式及其优缺点
[转] 第一种,prototype的方式: //父类 function person(){ this.hair = 'black'; this.eye = 'black'; this.skin = ' ...
- spring ioc三种注入方式
spring ioc三种注入方式 IOC ,全称 (Inverse Of Control) ,中文意思为:控制反转 什么是控制反转? 控制反转是一种将组件依赖关系的创建和管理置于程序外部的技术. 由容 ...
- Map三种遍历方式
Map三种遍历方式 package decorator; import java.util.Collection; import java.util.HashMap; import java.util ...
- php 递归函数的三种实现方式
递归函数是我们常用到的一类函数,最基本的特点是函数自身调用自身,但必须在调用自身前有条件判断,否则无限无限调用下去.实现递归函数可以采取什么方式呢?本文列出了三种基本方式.理解其原来需要一定的基础知识 ...
随机推荐
- 探索Win32系统之窗口类(转载)
Window Classes in Win32 摘要 本文主要介绍win32系统里窗口类的运做和使用机制,探索一些细节问题,使win32窗口类的信息更加明朗化. 在本文中,"类", ...
- 解决This function or variable may be unsafe
工程名字右键属性-->C/C++-->预处理器-->预处理器定义-->加入:_CRT_SECURE_NO_WARNINGS
- c++中char*\wchar_t*\string\wstring之间的相互转换
string U2A(const wstring& str)//Unicode字符转Ascii字符 { string strDes; if ( str.empty() ) goto __end ...
- 【leetcode❤python】217. Contains Duplicate
#-*- coding: UTF-8 -*- class Solution(object): def containsDuplicate(self, nums): numsdic= ...
- UVA 607 二十二 Scheduling Lectures
Scheduling Lectures Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submi ...
- Burpsuite之Http Basic认证爆破
有的时候经常遇到401.今天正好朋友问怎么爆破,也顺便记录一下 怕忘记了 referer:http://www.2cto.com/Article/201303/194449.html 看到Burpsu ...
- plot bar chart using python
Example import matplotlib.pyplot as plt import plotly.plotly as py # Learn about API authentication ...
- SynchronizationContext的研究之一(非WPF及Forms)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- STL--STL和她的小伙伴们:
STL--概述: 标准模板库(StandardTemplateLibrary,STL),是C++程序设计语言标准模板库.STL是由Alexander Stepanov.Meng Lee和David R ...
- git原理图解
本文背景,在实际项目中使用git已有一年,发现不少同事虽然会使用常用git指令,但并不理解每个指令对应的作用原理.今天静下心总结下git 的基本理解:代码的存在区域:本文以实际项目出发,理清使用git ...