(1) define the defineprogressdialog class, inherit the progressdialog, and rewrite the oncreate () method.
Package COM. lizhen. animation; import COM. lizhen. key. study. r; import android. app. progressdialog; import android. content. context; import android. OS. bundle; import android. widget. textview; public class defineprogressdialog extends progressdialog {private string message; private textview define_progress_msg; Public defineprogressdialog (context) {super (context); message = "loading... "; // todo auto-generated constructor stub} public defineprogressdialog (context, string message) {super (context); this. message = message;} @ overrideprotected void oncreate (bundle savedinstancestate) {// todo auto-generated method stubsuper. oncreate (savedinstancestate); setcontentview (R. layout. define_progress_dialog); define_progress_msg = (textview) findviewbyid (R. id. define_progress_msg); define_progress_msg.settext (Message );}}
(2) define_progress_msg.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/progress_bg" android:orientation="vertical" android:paddingBottom="10sp" android:paddingTop="10sp" android:paddingLeft="10sp" android:paddingRight="10sp" > <ProgressBar android:id="@+id/ios_progressbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" style="@style/DefineprogressBarStyleSmall"/><TextView android:id="@+id/define_progress_msg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:textSize="12sp"/></LinearLayout>
(3) set the progress bar style, customize defineprogressbarstylesmall, and add define_progressbar to the style:
<?xml version="1.0" encoding="utf-8"?><resources> <style name="DefineprogressBarStyleSmall" parent="android:style/Widget.ProgressBar"><item name="android:indeterminateDrawable">@drawable/progress</item><item name="android:minWidth">48dp</item> <item name="android:maxWidth">48dp</item> <item name="android:minHeight">48dp</item> <item name="android:maxHeight">48dp</item> </style></resources>
(4) define another progress bar background image, set the animation of the image, rotate around the center, and add progress. xml under drawable:
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <rotate android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="360" android:drawable="@drawable/progress_round" > </rotate> </item></layer-list>