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

Meaningful Motion: Circular Reveal with Shared Elements

Meaningful Motion: Circular Reveal with Shared Elements

A lightning talk about implementing a circular reveal effect with shared element transitions on Android.

https://medium.com/@jossiwolf/meaningful-motion-circular-reveal-shared-elements-ea495b99adf4

Jossi Wolf

January 30, 2018
Tweet

More Decks by Jossi Wolf

Other Decks in Programming

Transcript

  1. override fun onClickRecyclerViewItem(view: RoundedColorView) { Intent(this, SecondActivity::class.java).apply { val transitionActivityOptions

    = ActivityOptions.makeSceneTransitionAnimation( this@MainActivity, view, getString(R.string.transitionName)) startActivity(this, transitionActivityOptions.toBundle()) } } @jossiwolf
  2. override fun onClickRecyclerViewItem(view: RoundedColorView) { Intent(this, SecondActivity::class.java).apply { val transitionActivityOptions

    = ActivityOptions.makeSceneTransitionAnimation( this@MainActivity, view, getString(R.string.transitionName)) startActivity(this, transitionActivityOptions.toBundle()) } } @jossiwolf
  3. override fun onClickRecyclerViewItem(view: RoundedColorView) { Intent(this, SecondActivity::class.java).apply { val transitionActivityOptions

    = ActivityOptions.makeSceneTransitionAnimation( this@MainActivity, view, getString(R.string.transitionName)) startActivity(this, transitionActivityOptions.toBundle()) } } @jossiwolf
  4. override fun onClickRecyclerViewItem(view: RoundedColorView) { Intent(this, SecondActivity::class.java).apply { val transitionActivityOptions

    = ActivityOptions.makeSceneTransitionAnimation( this@MainActivity, view, getString(R.string.transitionName)) startActivity(this, transitionActivityOptions.toBundle()) } } @jossiwolf
  5. // Android Framework Method fun createCircularReveal(view: View, centerX: Int, centerY:

    Int, startRadius: Float, endRadius: Float): Animator { ... } @jossiwolf
  6. fun reveal() { collapsingToolbarBackground.setBackgroundColor(Color.CYAN) val center = roundedImage.getCenter() // create

    the animator for this view (the start radius is zero) val anim = ViewAnimationUtils.createCircularReveal(collapsingToolbarBackground, center.first.toInt(), center.second.toInt(), 0f, collapsingToolbarBackground.width.toFloat()) .apply { duration = 400 } } @jossiwolf
  7. fun reveal() { collapsingToolbarBackground.setBackgroundColor(Color.CYAN) val center = roundedImage.getCenter() // create

    the animator for this view (the start radius is zero) val anim = ViewAnimationUtils.createCircularReveal(collapsingToolbarBackground, center.first.toInt(), center.second.toInt(), 0f, collapsingToolbarBackground.width.toFloat()) .apply { duration = 400 } // make the view visible and start the animation collapsingToolbarBackground.visibility = View.VISIBLE anim.start() } @jossiwolf
  8. “Real-world forces, like gravity, inspire an element’s movement along an

    arc rather than in a straight line.” @jossiwolf
  9. // Create a new TransitionSet and inflate a transition from

    the resources val inSet = TransitionSet() val inflater = TransitionInflater.from(this) val transition = inflater.inflateTransition(R.transition.arc) // Add the inflated transition to the set and set duration and interpolator inSet.apply { addTransition(transition) duration = 380 // The shared element should not move in linear motion interpolator = AccelerateDecelerateInterpolator() } @jossiwolf
  10. // Create a new TransitionSet and inflate a transition from

    the resources val inSet = TransitionSet() val inflater = TransitionInflater.from(this) val transition = inflater.inflateTransition(R.transition.arc) // Add the inflated transition to the set and set duration and interpolator inSet.apply { addTransition(transition) duration = 380 // The shared element should not move in linear motion interpolator = AccelerateDecelerateInterpolator() } @jossiwolf
  11. // Create a new TransitionSet and inflate a transition from

    the resources val inSet = TransitionSet() val inflater = TransitionInflater.from(this) val transition = inflater.inflateTransition(R.transition.arc) // Add the inflated transition to the set and set duration and interpolator inSet.apply { addTransition(transition) duration = 380 // The shared element should not move in linear motion interpolator = AccelerateDecelerateInterpolator() } @jossiwolf
  12. // Create a new TransitionSet and inflate a transition from

    the resources val inSet = TransitionSet() val inflater = TransitionInflater.from(this) val transition = inflater.inflateTransition(R.transition.arc) // Add the inflated transition to the set and set duration and interpolator inSet.apply { addTransition(transition) duration = 380 // The shared element should not move in linear motion interpolator = AccelerateDecelerateInterpolator() } @jossiwolf