Android Custom ProgressDialog

Source: Internet
Author: User

1.
Import Customprogressdialog.java


2.
Styles.xml:

<style name= "Customprogressdialog" parent= "@android: Style/theme.dialog" >
<item name= "Android:windowbackground" > @android:color/transparent</item>
<item name= "Android:windownotitle" >true</item>
<item name= "Android:windowframe" > @null </item>
<item name= "Android:windowisfloating" >true</item>
<item name= "Android:windowcontentoverlay" > @null </item>
<item name= "Android:windowanimationstyle" > @android:style/animation.dialog</item>
<item name= "Android:windowsoftinputmode" >stateUnspecified|adjustPan</item>
</style>

3.
Define your own layout in \layout:

<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout
Xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:orientation= "Horizontal" >
<imageview
Android:id= "@+id/loadingimageview"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:background= "@anim/progress_round"/>
<textview
Android:id= "@+id/id_loadingmsg"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:layout_gravity= "Center_vertical"
Android:textsize= "20DP"/>
</LinearLayout>

4.
To achieve the effect of rotation, the picture is displayed cyclically:
Anim in Progress_round.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/progress_1" android:duration= "/>"
<item android:drawable= "@drawable/progress_2" android:duration= "/>"
<item android:drawable= "@drawable/progress_3" android:duration= "/>"
<item android:drawable= "@drawable/progress_4" android:duration= "/>"
<item android:drawable= "@drawable/progress_5" android:duration= "/>"
<item android:drawable= "@drawable/progress_6" android:duration= "/>"
<item android:drawable= "@drawable/progress_7" android:duration= "/>"
<item android:drawable= "@drawable/progress_8" android:duration= "/>"
</animation-list>

5.
Use

Import Com.youthforty.xxxxxx.CustomProgressDialog;

......

Private Customprogressdialog Pdialog=null;

......

if (Pdialog = = null) {
Pdialog = Customprogressdialog.createdialog (login.this);
Pdialog.setmessage ("Loading in ...");
}
Pdialog.show ();

......


Pdialog.dismiss ();

Android Custom ProgressDialog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.