首先先在res\anim下建一个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/list1" android:duration="200" />
<item android:drawable="@drawable/list2" android:duration="200" />
</animation-list>
然后在res\values下建一个styles.xml文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="newProgressStyle" parent="@android:style/Widget.ProgressBar.Small">
<item name="android:indeterminateDrawable">@anim/test</item>
</style>
</resources>
最后再在属性中加入style
<ProgressBar android:id="@+id/bar2" android:layout_width="700px"
android:layout_height="wrap_content"
style="@style/newProgressStyle"
/>
修改颜色:
在我们的项目下新建一个 style.xml 文件
创建一个style 标签,集成系统默认样式,然后自定义一个新的progressDrawable 文件,随后面在layout 中的progress 中引用这个文件就行
<style name="ProgressBar_Mini" parent="@android:style/Widget.ProgressBar.Horizontal">
<item name="android:maxHeight">50dip</item>
<item name="android:minHeight">8dip</item>
<item name="android:indeterminateOnly">false</item>
<item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
<item name="android:progressDrawable">@drawable/progressbar_mini</item>
</style>
下面是我的 progressbar_mini
文件,改变了下android:endColor="#F5F5F5" android:startColor="#BEBEBE" 的色值
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<shape >
<corners android:radius="5dip" />
<gradient
android:angle="270"
android:centerY="0.75"
android:endColor="#F5F5F5"
android:startColor="#BEBEBE" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip >
<shape >
<corners android:radius="0dip" />
<gradient
android:angle="270"
android:centerY="0.75"
android:endColor="#165CBC"
android:startColor="#85B0E9" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip >
<shape >
<corners android:radius="5dip" />
<gradient
android:angle="270"
android:centerY="0.75"
android:endColor="#165CBC"
android:startColor="#85B0E9" />
</shape>
</clip>
</item>
</layer-list>
最后在中引用就可以了
<ProgressBar
android:id="@+id/progress"
style="@style/ProgressBar_Mini"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:progress="50" />