Android custom ProgressDialog progress waiting box
Android itself has provided a ProgressDialog progress waiting box. Using this dialog, we can provide users with a better experience: when the network requests, this box pops up and waits for network data. However, since it is to improve the user experience, we certainly hope that the dialog can be more cool and make users look more comfortable. How to do that? Of course, we define a ProgressDialog ourselves. You can take a look at the dialog effect diagram to be implemented next:
Step 1: to define a layout file, the layout file is the dialog layout
In the layout file, we only define two components, an ImageView for displaying the rotation diagram and a textview for displaying the message text
Step 2: define the animation so that the picture on the pop-up box can rotate continuously.
Step 3: implement custom dialog logic
The code comments are very detailed. One thing to note is that when creating a dialog instance, you need to pass a theme, which is the style of dialog:
Step 4: use the custom ProgressDialog. Next, we can directly use the defined dialog. It is very simple. We only need to display and close the dialog. It is recommended to encapsulate the presentation method and put it in the
Through the above steps, we have completed the customized ProgressDialog. Of course, the specific effects required in the project can be adjusted.