轉載:http://www.eoeandroid.com/forum.php?mod=viewthread&tid=76872
一、通過動畫實作
定義res/anim/loading.xml如下:
[java] view
plaincopy
<?xml version="1.0" encoding="utf-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="150" android:drawable="@drawable/loading_01" />
<item android:duration="150" android:drawable="@drawable/loading_02" />
<item android:duration="150" android:drawable="@drawable/loading_03" />
<item android:duration="150" android:drawable="@drawable/loading_04" />
<item android:duration="150" android:drawable="@drawable/loading_05" />
<item android:duration="150" android:drawable="@drawable/loading_06" />
<item android:duration="150" android:drawable="@drawable/loading_07" />
</animation-list>
在layout檔案中引用如下:
<progressbar android:id="@+id/loading_process_dialog_progressbar"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:indeterminate="false" android:indeterminatedrawable="@anim/loading" />
二、通過自定義顔色實作
定義res/drawable/dialog_style_xml_color.xml如下:
<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="#ffffff" android:centercolor="#ffdc35"
android:centery="0.50" android:endcolor="#ce0000" />
</shape>
</rotate>
android:indeterminate="false" android:indeterminatedrawable="@drawable/dialog_style_xml_color" />
三、使用一張圖檔進行自定義
定義res/drawable/dialog_style_xml_icon.xml如下:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate android:drawable="@drawable/dialog_progress_round"
android:fromdegrees="0.0" android:todegrees="360.0" android:pivotx="50.0%"
android:pivoty="50.0%" />
</item>
</layer-list>
main.xml如下:
之後通過三個按鈕将progressbar 放在對話框中顯示出來就完成了。

animroundprocessdialog.rar
截圖如下: