[Android UI] ProgressBar自定义
转载自: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自定义的更多相关文章
- 【Android UI】自定义带按钮的标题栏
自定义标题栏在很多的android app中很常见,可以说是一种很有用的UI设计方法.自 己也本着学习的态度,经过一番各种坑,终于实现了,现总结如下: 一:大致流程 1. 对指定的andro ...
- Android UI组件----自定义ListView实现动态刷新
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...
- Android UI 学习 自定义的布局 平滑移动 VelocityTracker()
/** * Helper for tracking the velocity of touch events, for implementing * flinging and other such ...
- [Android UI] listview 自定义style
<style name="comm_listview_style"> <item name="android:cacheColorHint"& ...
- Android UI组件----ListView列表控件详解
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...
- AndroidのUI设计研究(一)——自定义ProgressBar
最近迷上进度条,使用进度条可以增强用户体验,让用户心里有个底,再无奈的等待中体会loading的乐趣. 记得以前优乐美的官网,进入主页加载资源,显示给用户看的就是,炫彩背景下,一个杯子里的奶茶随着加载 ...
- Android UI 绘制过程浅析(五)自定义View
前言 这已经是Android UI 绘制过程浅析系列文章的第五篇了,不出意外的话也是最后一篇.再次声明一下,这一系列文章,是我在拜读了csdn大牛郭霖的博客文章<带你一步步深入了解View> ...
- [转]Android UI:看看Google官方自定义带旋转动画的ImageView-----RotateImageView怎么写(附 图片淡入淡出效果)
http://blog.csdn.net/yanzi1225627/article/details/22439119 众所周知,想要让ImageView旋转的话,可以用setRotation()让其围 ...
- Android UI:看看Google官方自定义带旋转动画的ImageView-----RotateImageView怎么写(附 图片淡入淡...)
众所周知,想要让ImageView旋转的话,可以用setRotation()让其围绕中心点旋转,但这个旋转是不带动画的,也就是旋转屏幕时图片噌的一下就转过去了,看不到旋转的过程,此UI体验不大好,为此 ...
随机推荐
- 【poj1001】 Exponentiation
http://poj.org/problem?id=1001 (题目链接) 题意 求实数R的n次方,要求高精度. Solution SB题Wa了一下午,直接蒯题解. 高精度,小数点以及去前导后导零很麻 ...
- C/C++代码中的笔误
1. 在printf()的参数前加& (2015/10/7) 这是我写的一个数据生成器(generator)片段 +; printf("%d\n", &n);
- Xcode7中新技术
Xcode7真加了两个重要的debug功能:1:Address Sanitizer: 再也不用担心 EXC_BAD_ACCESS 在项目的Scheme中Diagnostics下,选中enable ad ...
- Nagios页面介绍(四)
四.nagios页面介绍 Nagios 4.0.8版本登录后图片
- vagrant 启动错误
Stderr: VBoxManage.EXE: error: Failed to create the VirtualBox object!VBoxManage.EXE: error: Code E_ ...
- STL中算法
sort 大数据量时,采用Quick Sort,分段递归排序: 小数据量时,采用Insert Sort. 如果迭代层次过深,会导致快排性能退化,这时采用Heap Sort排序. 快排pivot采用三点 ...
- WPF 复制和粘贴
/// <summary> /// 复制或剪切文件到剪切板 /// </summary> /// <param name="files">文件路 ...
- CentOS创建免密码SSH(密钥)
1.输入以下命令:ssh-keygen -t rsa 2.输入命令ls:产生两个文件:id_rsa id_rsa.pub 3.复制id_rsa.pub,并命名为authorized_key cp ~/ ...
- Linux无法使用userdel删除用户和组的解决办法
转自:http://www.linuxidc.com/Linux/2013-07/87371.htm 简述: 今天在看书的时候,看到有个实例,手痒痒的跟着做了起来...但是,出现问题了..测试的用户和 ...
- 繁华模拟赛 ljw分雕塑
/* 用f[i][k]表示考虑到第i个雕塑,分成k组,可不可行(这是一个bool类型的数组) 转移: f[i][k]=f[j][k-1],sum[i]-sum[j]合法 */ #include < ...