渐变的ProgressBar

在drawable中创建一张图片progress_bar.xml:

<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="0"
/>
</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="0"
/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners
android:radius="5dip" />
<gradient
android:startColor="#80ff0000"
android:endColor="#8000ff00"
android:angle="0" />
</shape>
</clip>
</item>

</layer-list>

引用这张图片:

<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
android:progress="80"
android:secondaryProgress="90"
android:progressDrawable="@drawable/progress_bar"
/>

对应的代码:
progressBar1.setProgressDrawable(getResources().getDrawable(R.drawable.progress_bar));
效果:

[img]http://dl.iteye.com/upload/attachment/419244/fafdb195-cadf-3b5b-bca3-857fbf5fbadb.png[/img]

progressBar常用方法:
[url]http://only81.iteye.com/blog/531242[/url]

[size=x-large][color=red]android圆形进度条颜色的设置[/color][/size]
<ProgressBar 
android:id="@+id/loadProgressBar"
android:indeterminateDrawable="@drawable/progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

其中的indeterminteDrawable属性就是用来设置进度条颜色等属性的,其内容如下:

<?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="#000000"
android:centerColor="#FFFFFF"
android:centerY="0.50"
android:endColor="#FFFF00" />

</shape>
</rotate>


Android自定义进度条-带文本(文字进度)的水平进度条(ProgressBar)
[url]http://orgcent.com/android-text-progressbar/[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值