Material Animations - A Deep Dive into Motion Design and Animation
A deep dive into the world of animation in Material Design. We'll cover what Material Design is, how natural motion plays a role in its principles and how to create meaningful animations that exhibit the essence of Material Design aims for.
large/complex transitions • 225ms for objects entering the screen LinearOutSlowInInterpolator • 195ms for objects leaving the screen FastOutLinearInInterpolator
states (i.e Enter, Exit, Reenter and Return) • Follows the same order as Window Transitions • Are drawn in the DecorView’s ViewOverlay • Transition API utilizes Scenes to hold view properties to animate between
destination Activity • The initial state of the Shared Element is positioned on top of the destination Activity’s View Hierarchy • The Shared Element is animated from its initial state to its final state • Animations are reversed when returning to the previous Activity
explode exit transition to the initial Activity 3. Share the selected view 4. Add the slide enter tranisition to the destination Activity 5. Add the FAB transform transition
buildTransitionPairs(view); Intent intent = new Intent(this, DetailActivity.class); // pass the background color to set on the shared element view in the {@code DetailActivity} intent.putExtra(DetailActivity.EXTRA_BG_COLOR, backgroundColor); // pass the id (position of the view in the ItemAdapter) of the view to use to build the // unique transitionName in the {@code DetailActivity} intent.putExtra(DetailActivity.EXTRA_ID, id);
buildTransitionPairs(view); Intent intent = new Intent(this, DetailActivity.class); // pass the background color to set on the shared element view in the {@code DetailActivity} intent.putExtra(DetailActivity.EXTRA_BG_COLOR, backgroundColor); // pass the id (position of the view in the ItemAdapter) of the view to use to build the unique transitionName in the {@code DetailActivity} intent.putExtra(DetailActivity.EXTRA_ID, id); ActivityCompat.startActivity(this, intent, ActivityOptionsCompat.makeSceneTransitionAnimation(this, pairs.toArray(new Pair[pairs.size()])).toBundle());
and background color to the View ActivityDetailBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_detail); binding.setId(getIntent().getIntExtra(EXTRA_ID, 0)); binding.item.setBackgroundColor(getIntent().getIntExtra(EXTRA_BG_COLOR, 0));
android:interpolator=“@android:interpolator/accelerate_decelerate"> <arcMotion android:maximumAngle="50"/> </changeBounds> // on FAB click, load the fab transition add the FabTransitionCallback Transition transition = TransitionInflater.from(view.getContext()).inflateTransition(R.transition.fab_transition); transition.addListener(new FabTransitionCallback(fab, revealContainer, revealTextView));
android:interpolator=“@android:interpolator/accelerate_decelerate"> <arcMotion android:maximumAngle="50"/> </changeBounds> // on FAB click, load the fab transition add the FabTransitionCallback Transition transition = TransitionInflater.from(view.getContext()).inflateTransition(R.transition.fab_transition); transition.addListener(new FabTransitionCallback(fab, revealContainer, revealTextView)); // 1. saves the current property values of all views in the rootView // 2. adds an OnPreDrawListener which is triggered on the next layout pass TransitionManager.beginDelayedTransition(rootView, transition);
android:interpolator="@android:interpolator/accelerate_decelerate"> <arcMotion android:maximumAngle="50"/> </changeBounds> // on FAB click, load the fab transition add the FabTransitionCallback Transition transition = TransitionInflater.from(view.getContext()).inflateTransition(R.transition.fab_transition); transition.addListener(new FabTransitionCallback(fab, revealContainer, revealTextView)); // 1. saves the current property values of all views in the rootView // 2. adds an OnPreDrawListener which is triggered on the next layout pass TransitionManager.beginDelayedTransition(rootView, transition); // 3. triggers the OnPreDrawListener created in TransitionManager.beginDelayedTransition // 4. OnPreDrawListener retrieves the new property values // 5. the system calculates the before/after property values and runs the animations fab.setLayoutParams(new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, CENTER));