1.自定义水平进度条
在drawable中新建 horizontal_gridiant_progressbar.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<!-- 渐变由白到灰 -->
<gradient
android:endColor="@android:color/darker_gray"
android:startColor="@android:color/white" />
</shape>
</clip>
</item>
</layer-list>
在Layout中设置progressbar
1
2
3
4
5
6
7
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:max="100"
android:progress="80"
android:progressDrawable="@drawable/horizontal_gridiant_progressbar" />
2.自定义转动progressbar
在drawable中新建 animated_rotate_progressbar.xml
rotate_progressbar图片
1
2
3
4
5
6
7
8
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/rotate_progressbar"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
</animated-rotate>
在Layout中设置progressbar
1
2
3
4
5
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:indeterminateDrawable="@drawable/animated_rotate_progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
最终效果图: