An explanation of the use of Android animation interpolator

Source: Internet
Author: User

In order to achieve some effect when we write the animation, we often need to set the Interpolator, which is used to simulate the real life scene.

Interpolator (interpolator) is used to modify the animation effect, define the rate of change of animation, can make the existing animation effect accelerated (acceleration), decelerated (deceleration), repeated (repetition), bounced (bounce) and so on.

Structure diagram:


Common interpolator:

Acceleratedecelerateinterpolator rate changes at the beginning and end of the animation are slower, accelerating in the middle

Accelerateinterpolator at the beginning of the animation the rate change is slow, and then start to accelerate

Anticipateinterpolator starts back and then moves forward.

Anticipateovershootinterpolator starts back and then dumps a certain value and returns the last value.

Bounceinterpolator animation at the end of the play

Cycleinterpolator Animation Loop plays a specific number of times, rate changes along the sine curve

Decelerateinterpolator in the beginning of the animation and then slowly

Linearinterpolator change at constant rate

Overshootinterpolator forward a certain value before returning to its original position.

If the above interpolator does not meet your requirements, you can customize the interpolator.

Let's look at an effect



Here I've customized a interpolator to achieve a constant rotation.

public class Myinterpolator extends Linearinterpolator {private float factor;public myinterpolator () {this.factor = 0.15f ;} @Overridepublic float getinterpolation (float input) {return (float) (Math.pow (2, -10 * input) * Math.sin ((Input-factor/ 4) * (2 * Math.PI)/factor) + 1);}}

Code Link: Click to open link

An explanation of the use of Android animation interpolator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.