ProgressBar的这几种样式可以在代码中找到:
android4.4/frameworks/base/core/res/res/values:
<style name="Widget.ProgressBar"> <item name="android:indeterminateOnly">true</item> <item name="android:indeterminateDrawable">@android:drawable/progress_medium_white</item> <item name="android:indeterminateBehavior">repeat</item> <item name="android:indeterminateDuration">3500</item> <item name="android:minWidth">48dip</item> <item name="android:maxWidth">48dip</item> <item name="android:minHeight">48dip</item> <item name="android:maxHeight">48dip</item> <item name="android:mirrorForRtl">false</item> </style> <style name="Widget.ProgressBar.Large"> <item name="android:indeterminateDrawable">@android:drawable/progress_large_white</item> <item name="android:minWidth">76dip</item> <item name="android:maxWidth">76dip</item> <item name="android:minHeight">76dip</item> <item name="android:maxHeight">76dip</item> </style> <style name="Widget.ProgressBar.Small"> <item name="android:indeterminateDrawable">@android:drawable/progress_small_white</item> <item name="android:minWidth">16dip</item> <item name="android:maxWidth">16dip</item> <item name="android:minHeight">16dip</item> <item name="android:maxHeight">16dip</item> </style> <style name="Widget.ProgressBar.Inverse"> <item name="android:indeterminateDrawable">@android:drawable/progress_medium</item> </style> <style name="Widget.ProgressBar.Large.Inverse"> <item name="android:indeterminateDrawable">@android:drawable/progress_large</item> </style> <style name="Widget.ProgressBar.Small.Inverse"> <item name="android:indeterminateDrawable">@android:drawable/progress_small</item> </style> <style name="Widget.ProgressBar.Small.Title"> <item name="android:indeterminateDrawable">@android:drawable/progress_small_titlebar</item> </style> <style name="Widget.ProgressBar.Horizontal"> <item name="android:indeterminateOnly">false</item> <item name="android:progressDrawable">@android:drawable/progress_horizontal</item> <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item> <item name="android:minHeight">20dip</item> <item name="android:maxHeight">20dip</item> <item name="android:mirrorForRtl">true</item> </style>
Widget.ProgressBar.Small 来查看。
<item name="android:indeterminateDrawable">@android:drawable/progress_small_white</item>
在地址中
android4.4/frameworks/base/core/res/res/drawable
找到这个xml。他是一个动画。
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/spinner_white_16" android:pivotX="50%" android:pivotY="50%" android:framesCount="12" android:frameDuration="100" />
android:drawable="@drawable/spinner_white_16"
因此我们按照他的这个思路也可以自己设置ProgressBar的样式。
另外,我们可以通过
android:indeterminateDrawable="@drawable/image_process_animation"
引入我们自定义动画。
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/base_loading_large_icon" android:pivotX="50%" android:pivotY="50%" />