Custom Drawable for ProgressBar/ProgressDialog

后端 未结 8 1159
野性不改
野性不改 2020-11-22 10:33

Reading the limited documentation that Google has provided, I get the feeling that it is possible to change the look (drawable) of a ProgressBar/ProgressDialog by simply cre

8条回答
  •  面向向阳花
    2020-11-22 10:38

    I was having some trouble using an Indeterminate Progress Dialog with the solution here, after some work and trial and error I got it to work.

    First, create the animation you want to use for the Progress Dialog. In my case I used 5 images.

    ../res/anim/progress_dialog_icon_drawable_animation.xml:

    
        
        
        
        
        
    
    

    Where you want to show a ProgressDialog:

    dialog = new ProgressDialog(Context.this);
    dialog.setIndeterminate(true);
    dialog.setIndeterminateDrawable(getResources().getDrawable(R.anim.progress_dialog_icon_drawable_animation));
    dialog.setMessage("Some Text");
    dialog.show();
    

    This solution is really simple and worked for me, you could extend ProgressDialog and make it override the drawable internally, however, this was really too complicated for what I needed so I did not do it.

提交回复
热议问题