android中自定义进度条风格

首先,在drawable目录下定义progressbar.xml

<?xml version="1.0" encoding="utf-8"?>
<animated-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="#6BD3FF"
android:centerColor="#FF7121"
android:centerY="0.50" android:endColor="#FFFF00" />
</shape>

</animated-rotate>

设置progressbar的android:indeterminateDrawable属性

<ProgressBar android:id="@+id/progress"
android:indeterminateDrawable="@drawable/progressbar"
android:layout_width="25dip" android:layout_height="25dip"
style="?android:attr/progressBarStyleSmall"
android:layout_marginRight="10dip" />
即可

你可能感兴趣的:(android,进度条风格,自定义进度条)