Skip to content

Most visited

Recently visited


Physics-based Animations

Physics-based animation relies on the laws of physics to manifest a high degree of realism in animation. In our day-to-day life, when a change occurs, it comes with a physical transition that is natural for us to recognize. Similarly, animations that are more natural-looking, uninterrupted, and the ones that maintain momentum, are easily perceived by us.

How does physics-based animation work?

Physics-based animation uses the fundamentals of physics to build animations. An animation is driven by force. The animation comes to rest when the force reaches equilibrium. These animation APIs embeds physics to render a more natural-looking and flexible animation and you can expect a high degree of course correction and a reduction in jank.


Other animations available in Android are driven by fixed durations and with the changes in animation values. To change an animation during its run without introducing any visual disruption is highly challenging.

With physics-based animation, the animation can track velocity, flawlessly correct the course, and move naturally towards the new position. Animations keep momentum by keeping the velocity continuous, which renders a smooth transition from one value to another.

Difference between Animator-based animation and physics-based animation

Consider a scenario where the target value needs to change during the animation.

Animations that are built by using Animator are fairly static and have a fixed duration. To accommodate the change in the target value, you need to cancel the animation at the time of target value change, re-configure the animation with current value as the new start value, and add the new target value. Visually, this process creates an abrupt stop in the animation, and a disjointed movement afterwards.

Animations that are built by using the physics-based animation APIs are driven by force. The change in the target value results in a change in force. The new force applies on the existing velocity, which makes a continuous transition to the new target. This process results in a more natural-looking animation.

The following figures illustrate the difference between an Animator-based animation and a physics-based animation. The animation in figure 1 is built by using ObjectAnimator. The animation in figure 2 is built by using physics-based APIs.

Figure 1: Animation built by using ObjectAnimator

Figure 2: Animation built by using physics-based APIs

As shown in the velocity graphs below, the Animator-based animation cannot track its velocity. After reconfiguration, the animation re-started at a near-0 velocity in the next frame. The sudden change in the velocity resulted in a visual disconnection before and after the change in the target value.

Whereas, the physics-based animation can track its velocity. The change in the target value triggers the change in force. The new force is then set on the existing velocity. Due to this, the animation can move naturally towards the new position.

Establishing the contrast between sudden and gradual differences in velocity of an animator-based animation.Figure 3: Velocity graph of Animator-based animation

Establishing the contrast between sudden and gradual differences in velocity of physics-based animationFigure 4: Velocity graph of physics-based animation

The basics

The Android framework supports physics-based animations through the API. The following are the relevant classes:
This package is the primary API for animating a view. It contains classes that are used for creating and managing a physics-based animation.
A base class of the physics-based animation package. This class manages the animation lifecycle as well as common setup among all animations.
A direct subclass of the DynamicAnimation class. This class creates a spring animation that animates a property of a given view.
This class defines properties of a spring such as damping ratio and stiffness that are used in animation.
A direct subclass of the DynamicAnimation class. This class creates a fling animation that has an initial momentum and gradually slows down.

Adding support library

In order to use the physics-based support library, you must modify your app project's classpath dependencies within your development environment.

To add a support library to your application project:

  1. Open the build.gradle file of your application.
  2. Add the support library to the dependencies section.
    dependencies {
        compile ""

Spring Animation

Physics-based animations are driven by force. Spring force, is one such force that guides interactivity and motion. The properties of a spring, the value, and the velocity are used in creating a spring-based animation. For more information about spring-based animations, go to Spring Animation.

Fling Animation

Fling animation, a type of physics-based animation, has an initial momentum and gradually slows down. For more information about fling-based animations, go to Fling Animation.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)