An easing function describes the value of a property given a percentage of completeness. Thanks to Robert Penner for defining equations which drove animations with ease.
How do we do this android ? First lets see how we do animations with ValueAnimator.
Setting up Activity
Our XML layout
Setup simple Animation
ValueAnimator class provides a simple timing engine for running animations which calculate animated values and set them on target objects .
AnimatorSet class plays a set of Animator objects in the specified order. Animations can be set up to play together, in sequence, or after a specified delay.
We will be using these two classes to make our first animation.
This animations seems so boring. We need somthing cool.
Easing to make it awesome
ValueAnimator class accepts an evaluator, which defines on how the value is derived. So we make use of setEvaluator function and put our easing equations there to get the desired animation.
So make a class Easing implementing TypeEvaluator
Now we have the evaluate methods which tell the ValueAnimator on how it should evaluate.
What’s the calculate method here?
This method decides which easing equation we are going to use. There is a lot mentioned about equations here. You can edit this method based on any of the equations given and get your desired animation.
Now we are good with the Easing class and ready to include it in our ValueAnimator.