Android custom fan countdown example code

1、 Overview

To make complaints about it, I am Android Xiao Bai, who wrote the purpose only to reserve knowledge. But I think I might accidentally search my article. If I am just describing it simply, others cannot read it, maybe I will be tucking away.

Therefore, I still describe the problem and process clearly, which is also an explanation to myself. At the same time, this is my first article, and I should do it well;

Let's talk about the requirements first: in recent work, I need to do a countdown, which is the kind of animation countdown in which a circle is slowly eaten. Because I don't have enough knowledge, I only know to draw with canvas. I searched the Internet and found that either I drew a fan statically or I can't control the position and size of the control.... in short, I found a circle and learned a lot of canvas knowledge, However, because I am also an Android Xiaobai, I can't summarize the fan countdown of the animation I want (here, because I use this thing for the first time and am not familiar with some editing, so I don't need the effect drawing, but the code here is very simple. Friends who need it can take it directly and run it to see if it is the effect you need);

Finally, I had to ask a friend of mine. Now he is not a great God, but he is much better than me... To put it bluntly, I just moved his logic more... So ashamed... Because I just want to be a knowledge reserve

2、 Text

Just now we talked about using canvas, so let's customize a control and directly inherit the custom control of view;

SweepView.java:

After writing the custom view, it is obvious that we want to use it, so it is stated in the layout file: (however, it should be noted that if you want to control its position and size, you should wrap it with ViewGroup, and control it by setting the position and size of ViewGroup. As for why, I also want to know 0.0)

MainActivity.xml

Finally, draw the animation form in the code. The round fan Countdown:

MainActivity.java:

3、 Summary

In the custom view, I don't quite understand many things, because I don't know some methods of customization, but I think I will slowly understand the meaning of some methods in the future; Of course, if you accidentally read this article, I hope you can solve my doubts. I'm very grateful

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
分享
二维码
< <上一篇
下一篇>>