Picture loading progress bar for Android custom view basic development

After learning the basic usage of paint and canvas, we can start to practice. First, write a simple picture and load the progress bar. As usual, first look at the renderings, and then decide whether to look down:

Now that you have seen this, you should want to know about the picture loading progress bar. Let's first look at the specific usage, and then look at the implementation of the custom view:

It can be seen that the above usage is very simple. Adding our custom view to XML is exactly the same as adding textview or button, but with our own custom attributes. You can set the color of the circle, text color, size, etc. After that, the method used in mainactivity is also as simple as updating the progress of our progress bar when the progress of the picture is updated.

Let's talk about the process of implementing the custom progress bar. We only need to rewrite the ondraw() method. Obviously, our progress bar includes three parts: inner circle circle, outer circle arc and text in the middle. See the code for details:

Of course, in order to customize the size and color of the progress bar, we also use custom attributes, and in the constructor, we also need to load various attributes in XML:

Source code download: http://xiazai.jb51.net/201608/yuanma/circleprogress (jb51.net).rar

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.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>