圆形进度条(替换默认转圈图片)
<ProgressBar
style="@android:style/Widget.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/custom_progressbar"
android:indeterminateDuration="1000"
/>
android:indeterminateDrawable属性决定进度条动画
android:indeterminateDuration决定转圈快慢
@drawable/custom_progressbar动画定义如下:
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@mipmap/ic_custom_progress_bar"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">
</rotate>
android:drawable=”@mipmap/ic_custom_progress_bar” 此属性是进度条的图片资源
水平进度条(一般用于加载网页时显示)
<ProgressBar
android:id="@+id/webview_progressbar"
style="@style/progressBarHorizontal_color"
android:layout_width="match_parent"
android:layout_height="2dp" />
@style/progressBarHorizontal_color文件如下:
<style name="progressBarHorizontal_color"
parent="android:style/Widget.Holo.ProgressBar.Horizontal">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/progress_color_horizontal</item>
</style>
@drawable/progress_color_horizontal文件如下:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:angle="270"
android:centerColor="#ed0004"
android:centerY="0.75"
android:endColor="#ed0004"
android:startColor="#ed0004" />
</shape>
</clip>
</item>
</layer-list>