Android imitates the radar scanning effect of friends near wechat and QQ

1. General

Recently, I have been taking interns. Because there are many people, I haven't updated my blog for a long time. Today, I update an article about the effect of radar scanning nearby friends. In the future, I try to update an article every week. Let's see the effect first:

2. Realization

1. Effect analysis

The effect is divided into two parts, one is the custom radarview in the upper part, and the other is the viewpager in the lower part. As for how to achieve the effects of zooming and background virtualization, you can go to lazyviewpager, which is not introduced in detail here, but mainly realizes the scanning effect.

2. Realization of scanning effect

2.1 custom radarview draws six circles in the ondraw() method. As for the radius of the circle, we need to obtain the width and height of the control through the onmeasure (int widthmeasurespec, int hightmeasurespec) measurement method to determine the radius of the circle. The radius of each circle is 1 / 13F, 2 / 13F, 3 / 13F, 4 / 13F, 5 / 13F, 6 / 13F of the width, This is just a comfortable effect tested by yourself. Please see the code below:

2.2 next, you need to draw the user image in the middle. You can run to see if the six circles in the middle have achieved the effect. Don't look here. Draw the middle image directly in the ondraw() method:

2.3 finally, you only need to realize the scanning effect, and the control is basically completed. First, you need to start the thread and constantly call invalidate() to update the ondraw() method. Second, you need to be familiar with the class of scanning and rendering sweepgradient. If both of these two are OK, you will have a great success:

2.4. Here, let's take a look at the effect of scanning radarview

3. To achieve the effect of adding data to radarview group, we need to add ViewGroup to the points near our image, and here we need to customize it. Let's briefly talk about custom ViewGroup: 1) Onmeasure() measurement method is not mentioned here 2) As long as you find out what the onlayout () method is for, OK. The location of the child views in the ViewGroup is written in this method. In other words, some are close and others are far away, which is determined by the child Layout (Int l, int t, int r, int b) is determined. Let's look at the code below:

Source code download: http://xiazai.jb51.net/201611/yuanma/AndroidRadarScan (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
分享
二维码
< <上一篇
下一篇>>