Android custom dialog to achieve text dynamic loading effect
Before, I saw a question "loading..." on the technical Q & A. the last three points are dynamic. Such an effect is realized. After thinking about it, I didn't seem to think of a good way to deal with it. I tried it and realized it in the stupidest way. Let's look at the effect first:
I customize a dialog. The effect in loading is implemented inside the dialog, and the progress is controlled from the activity. The following is the dialog implementation class:
The layout file consists of a textview, a ProgressBar, and a dialog_ progress. xml
Because I didn't think of other ideas, I can only change the display of textview through timer.. (I also hope you can give me some advice. I really can't think of any other ideas at present.) the style of ProgressBar is described in detail in the fillet progress of Android custom horizontal progress bar in the previous article. It won't be repeated here. Dialog is like this. Then it calls mainactivity class
Here, the timer is also used to simulate the loading progress (I feel that the timer timing operation is much more convenient than the other two methods during writing). Click events are called directly in XML.
If the clickable attribute is not added, some mobile phone systems cannot call it by default (for those who have encountered Xiaomi before, this attribute is not added and the click event is not triggered). In addition, the writing method of this click event is not available in fragment and can only be triggered through setonclicklistener.
Update an implementation: thank it hero and get another usage of attribute animation. Here are some adjustments in the custom dialog:
Because the method of CSDN editing and uploading resources is not found, there is no code to add this attribute animation in the demo here. Friends in need can copy directly from here.
Click download: source code
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.