Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Transitions

Android Transitions

An exploration of the Transitions framework for animating the transition between two screens

108056ccba92f98fdbbabad534537573?s=128

Bryan Herbst

December 11, 2014
Tweet

Transcript

  1. Transitions Bryan Herbst Senior Software Engineer The Nerdery

  2. 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
  3. Scenes  Snapshot of a ViewGroup  Can be defined

    in Java or XML (or let the framework do it)
  4. Making a transition

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

    0f); anim.start();
  6. Making a transition (new) TransitionManager.beginDelayedTransition(mRoot, new Fade()); mButton.setVisibility(View.INVISIBLE);

  7. AutoTransition  Fade  Move  Resize

  8. 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
  9. Activity Transitions

  10. 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();