转载自:http://gundumw100.iteye.com/blog/1289348

1: 在JAVA代码中

在java代码中 ProgressBar      继承自View, 在android.widegt包中

ProgressDialog   继承自Dialog, 在 android.app包中。

2: 在XML文件中

ProgressBar 默认是圆形转圈。
当为ProgressBar设置style="?android:attr/progressBarStyleHorizontal",后ProgressBar变成水平进度条,可以设置progress 和maxprogress

ProgressBar 在默认情况下,如果设置其它的style:

<ProgressBar style="@android:style/Widget.ProgressBar.Inverse"/>                    中等大小
<ProgressBar style="@android:style/Widget.ProgressBar.Large.Inverse"/>          

<ProgressBar style="@android:style/Widget.ProgressBar.Small.Inverse"/>           小

a: 通过动画实现自定义ProgressBar

定义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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="false"
android:indeterminateDrawable="@anim/loading" />

b:通过自定义颜色实现

定义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: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="#FFDC35"
android:centerY="0.50"
android:endColor="#CE0000"
android:startColor="#FFFFFF"
android:type="sweep"
android:useLevel="false" />
</shape> </rotate>

在layout文件中引用如下:

<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView1"
android:layout_below="@+id/textView1"
android:indeterminateDrawable="@drawable/dialog_style_xml_color"
android:indeterminate="false"
android:indeterminateDuration="1000"
android:layout_marginTop="155dp" />

c、使用一张图片进行自定义

定义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/dx_loading_dialog_rotate_img"
android:fromDegrees="0.0"
android:pivotX="50.0%"
android:pivotY="50.0%"
android:toDegrees="360.0" />
</item> </layer-list>

在layout文件中引用如下:

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="false" android:indeterminateDrawable="@drawable/dialog_style_xml_icon" />

d: <animated-rotate/>旋转一张图片:

res/drawable/custom_progress_draw.xml:

<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/circular"
android:pivotX="50%"
android:pivotY="50%" />
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/circular"
android:pivotX="50%"
android:pivotY="50%" />

[Android UI] ProgressBar自定义的更多相关文章

  1. 【Android UI】自定义带按钮的标题栏

    自定义标题栏在很多的android app中很常见,可以说是一种很有用的UI设计方法.自 己也本着学习的态度,经过一番各种坑,终于实现了,现总结如下: 一:大致流程 1.      对指定的andro ...

  2. Android UI组件----自定义ListView实现动态刷新

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...

  3. Android UI 学习 自定义的布局 平滑移动 VelocityTracker()

    /**  * Helper for tracking the velocity of touch events, for implementing  * flinging and other such ...

  4. [Android UI] listview 自定义style

    <style name="comm_listview_style"> <item name="android:cacheColorHint"& ...

  5. Android UI组件----ListView列表控件详解

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...

  6. AndroidのUI设计研究(一)——自定义ProgressBar

    最近迷上进度条,使用进度条可以增强用户体验,让用户心里有个底,再无奈的等待中体会loading的乐趣. 记得以前优乐美的官网,进入主页加载资源,显示给用户看的就是,炫彩背景下,一个杯子里的奶茶随着加载 ...

  7. Android UI 绘制过程浅析(五)自定义View

    前言 这已经是Android UI 绘制过程浅析系列文章的第五篇了,不出意外的话也是最后一篇.再次声明一下,这一系列文章,是我在拜读了csdn大牛郭霖的博客文章<带你一步步深入了解View> ...

  8. [转]Android UI:看看Google官方自定义带旋转动画的ImageView-----RotateImageView怎么写(附 图片淡入淡出效果)

    http://blog.csdn.net/yanzi1225627/article/details/22439119 众所周知,想要让ImageView旋转的话,可以用setRotation()让其围 ...

  9. Android UI:看看Google官方自定义带旋转动画的ImageView-----RotateImageView怎么写(附 图片淡入淡...)

    众所周知,想要让ImageView旋转的话,可以用setRotation()让其围绕中心点旋转,但这个旋转是不带动画的,也就是旋转屏幕时图片噌的一下就转过去了,看不到旋转的过程,此UI体验不大好,为此 ...

随机推荐

  1. WPF 窗口在右下角出现,识别分辨率

    直接上代码. Point brp = SystemParameters.WorkArea.BottomRight;//当前桌面右下角的位置

  2. dao、domain、service、web、vo、Model这些层的功能是什么

    这些层次都是用来管理不同的代码,让代码具有更好的维护性.开发中一般采用三层架构即MVC的模式来进行开发,M:代表model,可以理解为javaBean:V:代表view,可以理解为jsp:c:代表co ...

  3. Lex和Yacc入门

     Lex和Yacc入门 标签: lexyacc 2013-07-21 23:02 584人阅读 评论(0) 收藏 举报  分类: Linux(132)  原文地址:http://coanor.blog ...

  4. absolute布局和css布局释疑

    jqueryui也不是万能的, 有时候, 也需要自己写一些, 由 css 和jquery结合的一些东西, 如: banner中, 依次播放的div等 ## 关于jquery设计的一些思想和理念?but ...

  5. 移动端富文本编辑器artEditor

    摘要: 由于手机上打字比较慢,并不适合长篇大论的文章,所以移动端的富文本编辑器很少.artEditor是一款基于jQuery的移动端富文本编辑器,支持插入图片,后续完善其他功能. 插件地址:https ...

  6. POJ 3537 Crosses and Crosses

    Crosses and Crosses Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 2237 Accepted: 821 Ca ...

  7. cocos2d-x创建精灵动画方式汇总

    1.创建精灵框架缓存,并向其中添加相应的动画文件(plist),最后,通过动画集缓存生产动画 CCSpriteFrameCache *cache = CCSpriteFrameCache::share ...

  8. 小白科普之JavaScript的数组

    一.与其他语言数据的比较    相同点:有序列表    不同点:js的数组的每一项可以保存任何类型的数据:数组的大小是可以动态调整的 二.数组创建的两种方法 1)  var colors = new ...

  9. shell kill掉含同一字符的关键字的进程

    如何kill掉进程名包含某个字符串的一批进程:kill -9 $(ps -ef|grep 进程名关键字|gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ') 观 ...

  10. hibernate杂记

    1.hibernate中get和load方法有什么不同? (1)执行get方法,会立即加载对象, 执行load方法,若不使用该对象,则不会立即执行查询操作. (2)load 方法可能会抛出 LazyI ...