PathMeasure imitation Alipay payment animation in Android

preface

In Android custom view, path may be used more and pathmeasure may be used less. As far as I am concerned, I have never used the API pathmeasure before. I see that others have combined pathmeasure and valueanimator to complete good animation effects, so I also learn pathmeasure and record it here.

PathMeasure

Constructor:

Forceclosed means:

Draw path in OnDraw (canvas)

When pathmeasure.setpath (path, false):

When pathmeasure.setpath (path, true):

You can see that when forceclosed = true, the path is closed and the corresponding path length becomes longer, that is, the length of the bevel is included.

Imitation Alipay payment animation View - LoadingView

effect:

Idea:

Drawing checkmarks and cross numbers is mainly to continuously draw new arc segments through valueanimator combined with getsegment(). Among them, the cross number is composed of two paths. When the first path is drawn, you need to call pathmeasure. Nextcontour() to jump to another path.

Getsegment() fills the obtained fragment into destpath. In Android 4.4 and below, it cannot be drawn. You need to call destpath.reset(), destpath.line (0,0)

Loadingview complete code:

github : https://github.com/xing16/LoadingView

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