@NonNull @Override protected Transition createTransition(@NonNull ViewGroup container, @NonNull View entering, @Nullable View leaving, boolean push) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return new TransitionSet() .setOrdering(ORDERING_TOGETHER) .addTransition(new Fade(Fade.OUT)) .addTransition(new Fade(Fade.IN)); } final TransitionSet transition = new TransitionSet() .addTransition(new ChangeBounds()) .addTransition(new ChangeClipBounds()) .addTransition(new ChangeTransform()); transition.setPathMotion(new ArcMotion()); return transition; }
@Override @NonNull protected Transition getTransition(@NonNull ViewGroup container, View from, View to, boolean isPush) { TransitionSet transition = new TransitionSet() .setOrdering(TransitionSet.ORDERING_SEQUENTIAL) .addTransition(new Fade(Fade.OUT)) .addTransition(new TransitionSet().addTransition(new ChangeBounds()).addTransition(new ChangeClipBounds()).addTransition(new ChangeTransform())) .addTransition(new Fade(Fade.IN)); transition.setPathMotion(new ArcMotion()); return transition; }
private void setTransition() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return; } final TransitionSet transition = new TransitionSet(); ChangeBounds transition1 = new ChangeBounds(); transition.addTransition(transition1); ChangeTransform transition2 = new ChangeTransform(); transition.addTransition(transition2); ChangeClipBounds transition3 = new ChangeClipBounds(); transition.addTransition(transition3); ChangeImageTransform transition4 = new ChangeImageTransform(); transition.addTransition(transition4); transition.setDuration(SHARED_ELEMENT_TRANSITION_DURATION); FastOutSlowInInterpolator interpolator = new FastOutSlowInInterpolator(); transition1.setInterpolator(interpolator); transition2.setInterpolator(interpolator); transition3.setInterpolator(interpolator); transition4.setInterpolator(interpolator); final GravityArcMotion pathMotion = new GravityArcMotion(); transition.setPathMotion(pathMotion); getWindow().setSharedElementEnterTransition(transition); getWindow().setSharedElementReturnTransition(transition); getWindow().setSharedElementsUseOverlay(false); Slide slide = new Slide(Gravity.TOP); slide.setInterpolator(new LinearOutSlowInInterpolator()); slide.addTarget(appBar); slide.setDuration(225); slide.setStartDelay(100); getWindow().setEnterTransition(slide); Slide slideOut = (Slide) slide.clone(); slideOut.setInterpolator(new FastOutLinearInInterpolator()); slideOut.setStartDelay(0); getWindow().setReturnTransition(slideOut); }