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 (); Mimageview.post (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 (r.id. loadingiv);}}
Create Progress_dialog.xml under the Layout folder
<?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: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= "http://schemas.android.com/apk /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>"
Usage:
Loadingprogressdialog dialog =new Loadingprogressdialog (mainactivity.this, "Loading ...", r.anim.frame);// Open Dialog.show ();//Hide Dialog.dismiss ();
Demo Address: Https://github.com/yangjie10930/LoadingAnim
Android implementation Load Animation dialog box