Android implements several ideas and methods of Alipay

Alipay was very hot during the new year. So what are the specific implementation methods of wheezing? Next, we will introduce the implementation process of these ideas one by one.

1. Customize the view to realize "wheezing"

So this implementation method needs to master almost all the methods of canvas and paint. It requires very high professional knowledge of programmers.

The advantages realized in this way are:

This is the most complex implementation method, but it has the highest compatibility and supports all Android devices.

Second, it has little memory requirements and hardly occupies any memory.

Let's take a look at how to achieve its effect:

Circle type:

Look at the renderings:

You can modify the following two places to produce a visually real ripple effect:

(1) the background image of Alipay is pale red with red ripples. Of course, you can also set the canvas to transparent light red.

② It's filled circle rendering, not my border rendering effect. You can turn circlepaint setStyle(Paint.Style.stroke); Change to paint Style. FILL. Then, fine tune the shaper's mpositions to achieve a ring fill gradient. You may think that when you watch Alipay, the inner circle is wavy and springing outward when opening the circle. In fact, it is a circular gradient. When the circle becomes bigger, the range of the gradient will increase. Naturally, you can see signs of diffusion around the color.

2. The attribute animation realizes wheezing

It only needs to master the basic attribute animation and add a little knowledge about threads.

Let's take a look at the implementation steps:

A custom view can implement a circle. The code is as follows:

The code is similar to the above, so there are no comments. Second, you can implement activity

III. The code of layout document is as follows:

Of course, for the above two implementation methods, I only set the circle border without filling. You can set it to fine tune the gradient value after filling.

Its attribute animation file circle_ scale_ animator. xml:

Another circle_ spread_ animator. XML is:

The renderings are as follows:

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