Search code examples
androidanimationandroid-studiotransitionscene

Android Difference between Scenes and Transitions, Animations, and when to use them


So I recently have been reading into transitions and animations on the developer site:

Animation

http://developer.android.com/training/animation/index.html

Scenes and transitions

http://developer.android.com/training/transitions/index.html

I do not see the big differences between these and think they are relatively the same.

I know transitions are more of switching between views and animations are more for adding a wow factor by for example making a button pop up when holding your finger on it, However I believe there is much more to it then just these.

I am looking for a detailed answer if possible on the differences between the two and when you should be using each?


Solution

  • I came across this article the other day trying to find the best practices for doing animations while using data binding. The author explained 2 approaches, in which he uses animation (with BindingAdapter, see approach No.1) and transition (with onRebindCallback, see approach No.2) respectively. I think the summary/comparison he wrote at the end answers your question at a high-level, too. I personally think the most important points are that animations provide more fine-grained control while transitions are reusable (even if your view slightly changes).

    Advantages of the BindingAdapter mechanism:

    • Fine-grained control — only the views you want to animate will animate
    • Less overhead than transitions (performance)
    • Very flexible — you can create whatever animation you want

    Advantages of the OnRebindCallback mechanism:

    • Simple to use
    • Don’t have to use custom attributes (or override default behavior)
    • Can animate many things with the same code (see Transition subclasses)