Slide 1

Slide 1 text

Transitions Bryan Herbst Senior Software Engineer The Nerdery

Slide 2

Slide 2 text

What is a Transition?  Easy way to animate a group of Views  Animates from one Scene to another Scene  Can be used to animate between Activities and Fragments

Slide 3

Slide 3 text

Scenes  Snapshot of a ViewGroup  Can be defined in Java or XML (or let the framework do it)

Slide 4

Slide 4 text

Making a transition

Slide 5

Slide 5 text

Making a transition (old) ObjectAnimator anim = ObjectAnimator.ofFloat(mButton, "alpha", 1f, 0f); anim.start();

Slide 6

Slide 6 text

Making a transition (new) TransitionManager.beginDelayedTransition(mRoot, new Fade()); mButton.setVisibility(View.INVISIBLE);

Slide 7

Slide 7 text

AutoTransition  Fade  Move  Resize

Slide 8

Slide 8 text

How it works 1. beginDelayedTransition() => Take a snapshot of ViewGroup 2. Update Views 3. On next layout pass, Android takes another snapshot and creates animations Note: you can also define Scenes in XML

Slide 9

Slide 9 text

Activity Transitions

Slide 10

Slide 10 text

Activity Transitions (API 21)  Request Window.FEATURE_ACTIVITY_TRANSITIONS and Window.FEATURE_CONTENT_TRANSITIONS in both Activities  Set a transition name on the View in both Activities  Create a Bundle with  Call startActivity(intent, transitionBundle); makeSceneTransitionAnimation(activity, sharedView, viewTransitionName).toBundle();