Android implementation Load Animation dialog box

Source: Internet
Author: User

Two for the first one.

Customize dialog box:

public class Loadingprogressdialog extends ProgressDialog {private animationdrawable manimation;private Context Mcontext;private ImageView mimageview;private String mloadingtitle;private TextView mloadingtv;private int mresid; Public Loadingprogressdialog (context context, String content, int id) {super (context); this.mcontext = context; This.mloadingtitle = Content;this.mresid = Id;setcanceledontouchoutside (true);} @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Initview (); InitData ();} private void InitData () {mimageview.setbackgroundresource (mresid); manimation = (animationdrawable) Mimageview.getbackground (); (new Runnable () {@Overridepublic void run () {Manimation.start ();}); Mloadingtv.settext (mloadingtitle);} public void SetContent (String str) {mloadingtv.settext (str);} private void Initview () {Setcontentview (r.layout.progress_dialog); Mloadingtv = (TextView) Findviewbyid ( R.ID.LOADINGTV); Mimageview = (ImageView) Findviewbyid ( loadingiv);}} 

Create Progress_dialog.xml under the Layout folder

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= " Android "    android:layout_width=" wrap_content "    android:layout_height=" wrap_content "    android:gravity= "Center"    android:layout_gravity= "center"    android:orientation= "vertical" >    <imageview        Android:id= "@+id/loadingiv"        android:layout_width= "wrap_content"        android:layout_height= "wrap_content"/ >    <textview        android:id= "@+id/loadingtv"        android:layout_width= "Wrap_content"        android: layout_height= "Wrap_content"        android:textcolor= "#ffffff"        android:textsize= "20SP"/></ Linearlayout>

Create the Anim folder under the Res folder and build the Frame.xml inside

Animation is a picture by frame, each one of the item is a picture, animation how many frames there are how many pictures, how many pictures there are how many item.

<?xml version= "1.0" encoding= "Utf-8"? ><animation-list    xmlns:android= " /res/android "    android:oneshot=" false ">    <item        android:drawable=" @drawable/loading_01 "        android:duration= "/>    <item        android:drawable=" @drawable/loading_02 "android:duration="        100 "/>    <item        android:drawable=" @drawable/loading_03 "        android:duration="    < "/>" Item        android:drawable= "@drawable/loading_04"        android:duration= "/></animation-list>"


Loadingprogressdialog dialog =new Loadingprogressdialog (mainactivity.this, "Loading ...", r.anim.frame);// Open ();//Hide Dialog.dismiss ();

Demo Address: Https://

Android implementation Load Animation dialog box

Related Article

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: 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.