Example of using Android to imitate wechat camera ring progress effect

preface

When you encounter new things in your daily life, you should immediately open the wechat video, record it and send it to your friends. This recording progress bar looks pretty good. It's written in imitation. It's not a complete high imitation of the style, but a imitation of the function. I won't say much now. Let's take a look at the detailed introduction.

Wechat effect:

Source code download:

GitHub code through train

Local download

Self made effect:

Implementation process:

1. Custom circle radius and ring color attributes:

2. Set 3 brushes to draw circles respectively, with light white background and white circle in the center.

3. Draw the background circle, center circle and arc in turn. Canvas. Drawarc(), the first parameter represents the size of arc circumscribed rectangle; The second and third parameters represent the starting angle. The current angle, - 90 degrees is the 12-point direction, and 0 degrees is the 3-point direction. Here, - 90 degrees is used as the starting angle; The fourth parameter indicates whether to fill with the center point as a sector, and false indicates to draw only a circular arc;

Draw arc parameters of drawarc() method

4. Timer, update the progress every 100 milliseconds, and set the total shooting time totaltime; Time conversion to progress range: 0-100;

5. Press to start shooting, just lift to finish shooting, and the progress returns to 0.

Complete code of ciclepercentview class:

Attachment: introduction to Android canvas drawarc method

public void drawArc(RectF oval,float startAngle,float sweepAngle,boolean useCenter,Paint paint)

Here are four different uses of drawarc. 1. Fill an arc without a center:

2. Filled arc with center (sector)

3. Only draw the circumference, excluding the center of the circle

4. Only draw the circle with the center (sector)

summary

The above is the whole content of this article. I hope the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message. Thank you for your support for 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
分享
二维码
< <上一篇
下一篇>>