Support Library for Transitions. Overview and comparison with Transitions-Everywhere

Google has just released Support Library for Transitions framework and everyone got excited. But wait. Should you really use it? The short answer is: “No, it’s too early”.

Two years ago I created my own Transitions backport library Transitions-Everywhere.

So let’s compare Transitions-Everywhere, Support Library 24.2.0 and Android framework version.

First of all, Transitions framework has two large revisions: KitKat and Lollipop. In KitKat version there are only two Transitions available — Fade and ChangeBounds.

What was added in Lollipop:

  1. New Slide, Explode, ChangeImageTransform, ChangeClipBounds and ChangeTransform transitions.
  2. Ability to use transition names for views. Just apply the same String transition name for view from the first to the second scene and they will be “matched”.
  3. Ability to provide epicenter. Explode animation uses it to calculate animation direction.
  4. Propagation logic. Start delays for animators can be calculated according to the distance to epicenter.
  5. Path motion. View can move in layout along an arc path.

So, current version of Support Library (24.2.0) has only backport of KitKat functionality: Fade and ChangeBounds.

And what’s already available with Transitions-Everywhere? Everything from the list above except ChangeTransform (works starting from API 21) and ChangeClipBounds (works starting from API 18). Also with Transitions-Everywhere you can use internal Transitions that was marked as @hide in framework: Recolor, Rotate, ChangeText, Crossfade and ChangeScroll. And two transitions were added by me: Scale and TranslationTransition. Also ability to inflate Transitions via xml is backported (for some reasons it’s not backported in Support Library yet). You can find more info about Transitions-Everywhere in my previous article.

Now let’s look at some other limitations of current Support Library version. Even two available transitions may not work as you expect.

The first issue is about missing suppress layout functionality. How can it affect you? Let’s try simple example.

We have a LinearLayout with text and button.

When we tap on the button the following code will be executed:

How it works with framework version on 24 API and with Transitions-Everywhere on 18 API:

How it works with Support Library on 18 API:

Button will “jump” after textView removes from the container.

UPD: The issue is fixed in 26.0.0-alpha1 version of the support library. Guys from Google copied my solution from Transitions-Everywhere into the support library.

The second issue:

Current View alpha value can be lost.

We have an ImageView with 50 percent alpha.

When button is clicked we execute:

How it works with framework version on 24 API and with Transitions-Everywhere on 18 API:

How it works with Support Library on 18 API:

The next is a bug that was fixed in Android 7.0.

Fade transition cannot continue animation properly when it was interrupted. We have an ImageView and we are changing visibility of view again while previous animation is still running. (Let’s say we’re applying changes when we receive response from network. So our animation should work fine and apply changed values even if previous animation was interrupted)

We will start animation with 500 ms duration and will apply new values after 300 ms.

How it works with framework version on 24 API and with Transitions-Everywhere on 18 API:

How it works with framework version on 23 API with Support Library on 18 API:

The next bug still exists in framework Transitions. In some cases if you apply more than two animators that animate visibility changes it will show two instances of view.

We have an ImageView and will apply Fade and Slide for it. It’s a really common task to mix motion with the fade animation.

How it works with framework version:

With Support Library you won’t be able to do that because Slide is not backported yet.

How it works with Transitions-Everywhere:

And the last bug is still exists in framework as well. Scene to scene changes will only once if you will provide null transition while documentation said that you can do it if you want just to change the views in the scene root without any animation. And scene root view will be stored in a static list forever, typical memory leak with a context.

Let’s hope that next versions of Support Library will have more backported functionality. But for now you can just add one line to your build.gradle:

More info about Transitions and backport