Bespoke Android App Developers: Interpolator

Bespoke Android App Developers: Interpolator

Android provides a built-in Interpolator library that allows you to create animations with various types of easing and acceleration. Interpolators are used to control the rate at which animations occur, creating smooth transitions between different states.

Android's Interpolator library includes several built-in interpolators that you can use:

  1. LinearInterpolator: This interpolator provides a linear animation, with constant speed throughout.

  2. AccelerateInterpolator: This interpolator starts slowly and then accelerates as the animation progresses.

  3. DecelerateInterpolator: This interpolator starts quickly and then decelerates as the animation progresses.

  4. AccelerateDecelerateInterpolator: This interpolator starts slowly, accelerates in the middle, and then decelerates again at the end.

  5. AnticipateInterpolator: This interpolator creates an animation that appears to overshoot the target value before settling into its final state.

  6. OvershootInterpolator: This interpolator creates an animation that overshoots the target value before settling into its final state.

  7. BounceInterpolator: This interpolator creates an animation that appears to bounce back and forth a few times before settling into its final state.

  8. CycleInterpolator: This interpolator creates an animation that cycles back and forth between the start and end values.

To use an interpolator in your Android application, you can create an instance of the desired interpolator class and pass it to your animation object. For example:

Interpolator interpolator = new AccelerateDecelerateInterpolator(); myAnimation.setInterpolator(interpolator);

This code sets an instance of the AccelerateDecelerateInterpolator class as the interpolator for the myAnimation animation object.

You can also create custom interpolators by extending the Interpolator class and implementing the getInterpolation() method. This method takes a float value between 0 and 1 as input and returns a float value that represents the progress of the animation at that point. You can use mathematical functions to create custom interpolation behaviors, such as logarithmic or exponential easing.


Android provides a set of built-in interpolators that can be used to control the rate of change of animations. These interpolators define the mathematical function used to interpolate between the start and end values of an animation.

Here are some of the commonly used interpolators:

  1. AccelerateDecelerateInterpolator - starts and ends slowly with a rapid acceleration in the middle.

  2. AccelerateInterpolator - starts slowly and accelerates quickly.

  3. DecelerateInterpolator - starts quickly and decelerates slowly.

  4. AnticipateInterpolator - starts the animation by moving backwards before reversing and moving forwards.

  5. OvershootInterpolator - overshoots the target value before returning to the final value.

  6. BounceInterpolator - creates a bouncing effect at the end of the animation.

  7. CycleInterpolator - creates an animation that repeats itself over a specified number of cycles.

All of these interpolators are available in the Android SDK and can be accessed through the Interpolator class. Additionally, you can create your own custom interpolator by implementing the Interpolator interface and defining your own mathematical function for the interpolation.

To use an interpolator in your animation, you can pass it as a parameter to the setInterpolator() method of your Animation or Animator object. For example, if you have an ObjectAnimator that changes the alpha value of a View, you can set the interpolator like this:

ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(myView, "alpha", 0f, 1f); alphaAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); alphaAnimator.start();

This will create an animation that smoothly accelerates and decelerates as the alpha value changes from 0 to 1.

Read more about Interpolator