How can I set my own ProgressDialog loading image?
I have animated gif image and when i try to use it in ProgressDialog it wont show.
ProgressDialog dialog = new ProgressD开发者_JS百科ialog(this);
dialog.setIcon(R.drawable.loading);
dialog.setTitle("Loading");
dialog.setMessage("Please wait...");
dialog.show();
What I`m doing wrong? How can I set my own loading image?
Maybe it's too late,but i have same question with you. And then i find the solution in this GitHub Code Repository And then here what i'am doing
- Android can't be automatically load gif so you must split your gif image into images. You can use this site to split your Gif. Copy split gif image into your drawable folder.
- Create custom progress dialog and custom layout.
- Create custom progress animation and then edit soruce image. and then change duration like what you want.
Change your code into like this
ProgressDialog dialog = new MyCustomProgressDialog.ctor(this); dialog.show();
and than your loading image has been change.
That code just show gif image, if you want settitle and setimage just change custom progress dialog and custom layout
The default loading image is not a gif image it's a combination of two images and then animating it around. view the source code it may help you in res.drawable/progress_large.xml of android.
You can use custom dialog instead of using the default ProgressDialog. Set images according to your need.
精彩评论