1
在需要显示进度盘的xml页面里
<ProgressBar
android:id="@+id/main_head_progress"
style="@style/loading_small"
android:layout_toRightOf="@id/main_head_title"
android:layout_centerVertical="true"
android:layout_marginLeft="5.0dip"
android:visibility="gone"/>
此处借用了style来设置格式,于是
2
在styles的xml文件中
<style name="loading_small" parent="@android:style/Widget.ProgressBar.Small">
<item name="android:indeterminateDrawable">@anim/loading</item>设置自定义
<item name="android:layout_width">21dip</item>
<item name="android:layout_height">21dip</item>
<item name="android:layout_gravity">center_vertical</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>
3
为了实现动态效果,在anim.xml文件中
<?xml version="1.0" encoding="UTF-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="100" android:drawable="@drawable/loading_0" />
<item android:duration="100" android:drawable="@drawable/loading_1" />
<item android:duration="100" android:drawable="@drawable/loading_2" />
<item android:duration="100" android:drawable="@drawable/loading_3" />
<item android:duration="100" android:drawable="@drawable/loading_4" />
<item android:duration="100" android:drawable="@drawable/loading_5" />
<item android:duration="100" android:drawable="@drawable/loading_6" />
<item android:duration="100" android:drawable="@drawable/loading_7" />
</animation-list>
这里是一组图片