开发者

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

  1. 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.
  2. Create custom progress dialog and custom layout.
  3. Create custom progress animation and then edit soruce image. and then change duration like what you want.
  4. Change your code into like this

    ProgressDialog dialog = new MyCustomProgressDialog.ctor(this); dialog.show();

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜