Android implements a custom gorgeous water ripple effect

Let's see the effect first

Simulate the effect of water ripple: click the screen and a ring will appear, with radius from small to large and transparency from large to small (0 is transparent)

Realization idea

1. Custom class inherits view.

2. Define the entity class wave of each ring and initialize the data of the brush drawing the ring.

3. Rewrite the ontouchevent method. When down, obtain the coordinate point as the center of the ring.

4. Send the handler information, modify the data and refresh the page.

5. Rewrite the OnDraw method to draw a ring.

1. Custom class inherits view

New waterwaveview2 class inherits view

2. Define the entity class wave

3. Override the ontouchevent method to obtain the center of the circle, delete the ring with transparency of 0 in the collection, and notify the handler to call ondraw() method

4. Override the ondraw() method to draw the ring in a loop

summary

The above is all about Android's implementation of custom water ripple effect. How about it? The effect is good. Interested partners quickly practice by themselves. I hope this article can be helpful to everyone's study and work.

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