Detailed explanation of Android attribute animation valueanimator and interpolator

Detailed explanation of Android attribute animation valueanimator and interpolator

1、 Valueanimator details:

Valueanimator is the core of the whole animation, and objectanimator is implemented by inheriting from valueanimator. Valueanimator is more like a numerical generator, which is used to generate numbers with certain rules, so that the caller can control the implementation process of animation.

1. Use of valueanimator:

2. Stop valueanimator Animation:

You can call the cancel () method or end () method of the valueanimator object. First, calling both methods will stop the animation, but the difference is

1. After calling cancel (), valueanimator will stop immediately and will not call back again. 2. After calling end(), valueanimator will directly call back the value of the end state of the animation, that is, if end() is called, the animation will stop directly to the end.

2、 Use of Android interpolator:

Interpolator can realize animation and attenuation effects, such as "gradually decrease", "gradually increase", "accelerate first and then decelerate"

Here are several commonly used interpolators:

1. Accelerated interpolator: the rate of change is an accelerated process from the beginning to the end of the animation. 2. Decelerateinterpolator: the rate of change is a deceleration process from the beginning to the end of the animation. 3. Cycleinterpolator: from the beginning to the end of the animation, the rate of change is the sine curve of a given number of cycles. 4. Accelerating decelerateinterpolator: from the beginning to the end of animation, the rate of change is the process of accelerating first and then decelerating. 5. Linear interpolator: the rate of change of the animation is linear from the beginning to the end.

1. Usage:

The principle of valueanimator can be seen from its source code:

2. Custom interpolator:

Thank you for reading, hope to help you, thank you for your support to this site!

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