Android O feature spotlight: More natural movement with physics-based animations

Android O feature spotlight: More natural movement with physics-based animations

0 30

Animations in apps can often be jerky or unrealistic, but in Android O Google plans to give developers tools to make animations buttery smooth and natural with the power of physics. It should also be much simpler to make animations with this system.

The flick animation
Right now, the Animator class is used to create animations, but they tend to look static and jerky. For a complex movement, you have to define one animation, cancel it, and define a new one each time you change direction. It can end up looking disjointed and mechanical.

The spring animation
By contrast, the new physics-based animations are driven by an API. Changes in direction are defined by simulated force, which the developer describes with new classes like SpringForce and FlingAnimation. With FlingAnimation, developers can input values for friction, velocity, and range. When using SpringForce, the dev feeds in things like start velocity, stiffness, and dampening.

Left: Old, Right: New physics-based
The GIFs above show the stark difference when you use the new physics-based tools compared to the old Animator class. The physics-based animation has realistic momentum, and the old version loses all its momentum and changes direction in an unnatural way.

Source:
Android Developers: 1,
2,
3

Article originally published at: Android Police