android圆形进度条ProgressBar颜色设置
花样android Progressbar http://www.eoeandroid.com/thread-1081-1-1.html
http://www.cnblogs.com/xirihanlin/archive/2010/06/14/1758145.html
xml布局文件需加入如下的进度条构件:
<ProgressBar
android:id="@+id/loadProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/progressbar" />
其中的indeterminteDrawable属性就是用来设置进度条颜色等属性的,其内容如下:
<?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="#FFFF00"
android:startColor="#000000"
android:type="sweep"
android:useLevel="false" />
</shape> </rotate>
参考:http://dev.10086.cn/cmdn/bbs/viewthread.php?tid=18469
http://tienfook.blog.163.com/blog/static/1666620112010528637217/
http://www.ihoton.com/androidandroid-progressbar-color.html
三种方式实现自定义圆形页面加载中效果的进度条:
来自:http://407827531.iteye.com/blog/1067025
默认情况下Indeterminate Progressbar是白色的,如果容器的背景也是白色的,这样就根本看不到Progressbar了。
幸好Android自带了一些反转样式,你可以采用其中一个合适的:
<ProgressBar style="@android:style/Widget.ProgressBar.Inverse"/>
<ProgressBar style="@android:style/Widget.ProgressBar.Large.Inverse"/>
<ProgressBar style="@android:style/Widget.ProgressBar.Small.Inverse"/>
进度条:
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ProgressBar
android:id="@+id/circleProgressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
mce_style="?android:attr/progressBarStyleLarge" />
一、通过动画实现
定义res/anim/loading.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" > <item
android:drawable="@drawable/loading_01"
android:duration="150"/> <item
android:drawable="@drawable/loading_02"
android:duration="150"/> <item
android:drawable="@drawable/loading_03"
android:duration="150"/> <item
android:drawable="@drawable/loading_04"
android:duration="150"/> <item
android:drawable="@drawable/loading_05"
android:duration="150"/> <item
android:drawable="@drawable/loading_06"
android:duration="150"/> <item
android:drawable="@drawable/loading_07"
android:duration="150"/> </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: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/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:pivotX="50.0%"
android:pivotY="50.0%"
android:toDegrees="360.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" />
或者
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient android:startColor="#ff9d9e9d"
android:centerColor="#ff5a5d5a"
android:centerY="0.75"
android:endColor="#ff747674"
android:angle="270"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient android:startColor="#80ffd300"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient android:startColor="@color/progress_start"
android:endColor="@color/progress_end"
android:angle="270" />
</shape>
</clip>
</item>
</layer-list>
代码中设置:
mProgress = (ProgressBar) findViewById(R.id.progress_bar);
Drawable d = this.getResources().getDrawable(R.drawable.my_progress);
mProgress.setProgressDrawable(d);
android圆形进度条ProgressBar颜色设置的更多相关文章
- 安卓ProgressBar水平进度条的颜色设置
安卓系统提供了水平进度条ProgressBar的样式,而我们在实际开发中,差点儿不可能使用默认的样式.原因就是"太丑"^_^ 所以我们在很多其它的时候须要对其颜色进行自己定义,主要 ...
- 【Android进度条】三种方式实现自定义圆形进度条ProgressBar
一.通过动画实现 定义res/anim/loading.xml如下: <?xml version="1.0" encoding="UTF-8"?> ...
- Android 三种方式实现自定义圆形进度条ProgressBar
一.通过动画实现 定义res/anim/loading.xml如下: <?xml version="1.0" encoding="UTF-8"?> ...
- Android——ProgressDialog 进度条对话框
public class ProgressDialogActivity extends Activity { private Button btn_large_pd, btn_horizonta ...
- android 自定义控件——(四)圆形进度条
----------------------------------↓↓圆形进度条(源代码下有属性解释)↓↓---------------------------------------------- ...
- Android 高手进阶之自定义View,自定义属性(带进度的圆形进度条)
Android 高手进阶(21) 版权声明:本文为博主原创文章,未经博主允许不得转载. 转载请注明地址:http://blog.csdn.net/xiaanming/article/detail ...
- Android 带进度的圆形进度条
最近项目有个需求,做带进度从下到上的圆形进度条. 网上查了一下资料,发现这篇博客写得不错http://blog.csdn.net/xiaanming/article/details/10298163 ...
- Android 高手进阶,自己定义圆形进度条
背景介绍 在Android 开发中,我们常常遇到各种各样绚丽的控件,所以,依靠我们Android本身所带的控件是远远不够的,许多时候须要我们自定义控件,在开发的过程中.我们公司遇到了一种须要自己写的一 ...
- Android 自定义 View 圆形进度条总结
Android 自定义圆形进度条总结 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 微信公众号:牙锅子 源码:CircleProgress 文中如有纰漏,欢迎大家留言指出. 最近 ...
随机推荐
- 用pc浏览器打开手机页面
原理是仿造http包头,下面已chrome为例. 方法:运行->输入如下手机操作系统对应的代码即可. 安卓: chrome.exe --user-agent="Mozilla/5.0 ...
- 转: css实现垂直居中的方法
利用 CSS 来实现对象的垂直居中有许多不同的方法,比较难的是选择那个正确的方法.我下面说明一下我看到的好的方法和怎么来创建一个好的居中网站. 用 CSS 实现垂直居中并不容易.有些方法在一些浏览器中 ...
- Linux android studio :'tools.jar' seems to be not in Android Studio classpath.
问题: 'tools.jar' seems to be not in Android Studio classpath.Please ensure JAVA_HOME points to JDK ra ...
- Python 連接 MySQL
Python 連接 MySQL MySQL 是十分流行的開源資料庫系統,很多網站也是使用 MySQL 作為後台資料儲存,而 Python 要連接 MySQL 可以使用 MySQL 模組.MySQLdb ...
- RAC Cache Fusion 原理理解
cache fusion . grd . drm . gcs . ges cache fusion 1.RAC是一个数据库执行在多个实例上.通过DLM(Distributed ...
- 微软阵营稳定的好消息:.NET开源、Visual Studio
自由
今天各个IT社区,头版头条说的是微软.NET开源了.宇宙中最好的IED–Visual Studio Community 2013将免费提供给用户的消息. <宇宙中最强大的开发环境免费了! > ...
- iOS NSRuntime机制
什么是Objective-C runtime? 简单来说,Objective-C runtime是一个实现Objective-C语言的C库.对象可以用C语言中的结构体表示,而方法(methods)可以 ...
- [转][Swust OJ 24]--Max Area(画图分析)
转载自:http://www.cnblogs.com/hate13/p/4160751.html Max Area 题目描述:(链接:http://acm.swust.edu.cn/problem/2 ...
- BZOJ 1042: [HAOI2008]硬币购物( 背包dp + 容斥原理 )
先按完全背包做一次dp, dp(x)表示x元的东西有多少种方案, 然后再容斥一下. ---------------------------------------------------------- ...
- Redis 突然报错 NOAUTH Authentication required
查找相关资料,说是添加了密码 只需要在redis的配置文件redis.conf中开启requirepass就可以了,比如我设置我的访问密码是mypassword requirepass mypassw ...