Why MotionLayout ?

The Android framework already provides several ways of adding animation in your application:

This section will cover how MotionLayout differs from those existing solutions.

MotionLayout, as its name hints at, is first of all a layout, letting you position your elements. It’s actually a subclass of ConstraintLayout, and builds upon its rich layout capabilities.

MotionLayout was created to bridge the gap between layout transitions and complex motion handling. You can think of it in terms of capabilities as a mix between the property animation framework, TransitionManager, and CoordinatorLayout.

A mix between the property animation framework, layout transitions with TransitionManager, and CoordinatorLayout

It lets you describe the transition between two layouts (like TransitionManager), but can animate any properties as well (not just layout attributes). Moreover, it inherently supports seekable transitions, like CoordinatorLayout (the transition can be driven purely by touch and transition to any point of it instantly). It supports touch handling and keyframes, allowing developers to easily customize transitions to their own needs.

MotionLayout is fully declarative

Beyond this scope, the other key difference is that MotionLayout is fully declarative — you can fully describe in XML a complex transition — no code is expected (if you need to express motion by code, the existing property animation framework already provides a great way of doing it).

MotionLayout tooling

We do believe that this focus on declarative motion specification will simplify creating such animations, as well as open the way to provide great graphical tooling in Android Studio.

While we are actively working on this tool, it’s not available yet. It will likely be available once the library reaches stable / beta.

Finally, as a part of ConstraintLayout 2.0, it is available as a support library, backwards compatible to API level 14 (ICS) : which means it supports 99.8% of current Android devices (see distribution chart).

Limitations

MotionLayout will only provide its capabilities for its direct children — contrary to TransitionManager, which can work with nested layout hierarchies as well as Activity transitions.