Preliminary study of Android Bezier curve lesson 3 motion trajectory added to shopping cart by Android implementation

I wonder if you still like the unread message bubble of high imitation QQ in the previous section. Today, we continue to practice the Bezier curve. In this section, we realize the motion trajectory added to the shopping cart through Bezier curve and attribute animation estimator. The effects are as follows:

1. Create a new custom view, rewrite the construction method, and initialize paint and path;

2. Determine the coordinates of start point, end point and control point. Here we directly fix:

3. Draw the starting and ending point ball and Bessel curve path:

In this way, the basic things are completed.

4. So how to make a small ball move along with the path of the Bezier curve, you need to get the coordinates of the current point on the Bezier curve, using the following tools:

The coordinates of the current point on the Bezier curve can be obtained by passing in the corresponding parameters. The curve length ratio T, start point and end point can be obtained in the attribute animation evaluator:

Note: the difference between point and PointF: point uses int type to store X and Y coordinates, while PointF uses float type.

5. Set click listening setonclicklistner (this), and override onclick method:

Use the object of the estimator bezierevaluator to obtain the current position in the attribute animation update listening, and redraw:

You can achieve a motion track effect similar to adding to the shopping cart.

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