Here are the examples of the java api class android.transition.ArcMotion taken from open source projects.
1. FabDialogMorphSetup#setupSharedEelementTransitions()
Project: sbt-android
File: FabDialogMorphSetup.java
File: FabDialogMorphSetup.java
/** * Configure the shared element transitions for morphin from a fab <-> dialog. We need to do * this in code rather than declaratively as we need to supply the color to transition from/to * and the dialog corner radius which is dynamically supplied depending upon where this screen * is launched from. */ public static void setupSharedEelementTransitions(@NonNull Activity activity, @Nullable View target, int dialogCornerRadius) { if (!activity.getIntent().hasExtra(EXTRA_SHARED_ELEMENT_START_COLOR)) return; int startCornerRadius = activity.getIntent().getIntExtra(EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS, -1); ArcMotion arcMotion = new ArcMotion(); arcMotion.setMinimumHorizontalAngle(50f); arcMotion.setMinimumVerticalAngle(50f); int color = activity.getIntent().getIntExtra(EXTRA_SHARED_ELEMENT_START_COLOR, Color.TRANSPARENT); Interpolator easeInOut = AnimationUtils.loadInterpolator(activity, android.R.interpolator.fast_out_slow_in); MorphFabToDialog sharedEnter = new MorphFabToDialog(color, dialogCornerRadius, startCornerRadius); sharedEnter.setPathMotion(arcMotion); sharedEnter.setInterpolator(easeInOut); MorphDialogToFab sharedReturn = new MorphDialogToFab(color, startCornerRadius); sharedReturn.setPathMotion(arcMotion); sharedReturn.setInterpolator(easeInOut); if (target != null) { sharedEnter.addTarget(target); sharedReturn.addTarget(target); } activity.getWindow().setSharedElementEnterTransition(sharedEnter); activity.getWindow().setSharedElementReturnTransition(sharedReturn); }
2. DesignerNewsStory#doFabExpand()
Project: sbt-android
File: DesignerNewsStory.java
File: DesignerNewsStory.java
private void doFabExpand() { // translate the chrome placeholder ui so that it is centered on the FAB int fabCenterX = (fab.getLeft() + fab.getRight()) / 2; int fabCenterY = ((fab.getTop() + fab.getBottom()) / 2) - fabExpand.getTop(); int translateX = fabCenterX - (fabExpand.getWidth() / 2); int translateY = fabCenterY - (fabExpand.getHeight() / 2); fabExpand.setTranslationX(translateX); fabExpand.setTranslationY(translateY); // then reveal the placeholder ui, starting from the center & same dimens as fab fabExpand.setVisibility(View.VISIBLE); Animator reveal = ViewAnimationUtils.createCircularReveal(fabExpand, fabExpand.getWidth() / 2, fabExpand.getHeight() / 2, fab.getWidth() / 2, (int) Math.hypot(fabExpand.getWidth() / 2, fabExpand.getHeight() / 2)).setDuration(fabExpandDuration); // translate the placeholder ui back into position along an arc ArcMotion arcMotion = new ArcMotion(); arcMotion.setMinimumVerticalAngle(70f); Path motionPath = arcMotion.getPath(translateX, translateY, 0, 0); Animator position = ObjectAnimator.ofFloat(fabExpand, View.TRANSLATION_X, View.TRANSLATION_Y, motionPath).setDuration(fabExpandDuration); // animate from the FAB colour to the placeholder background color Animator background = ObjectAnimator.ofArgb(fabExpand, ViewUtils.BACKGROUND_COLOR, ContextCompat.getColor(this, R.color.designer_news), ContextCompat.getColor(this, R.color.background_light)).setDuration(fabExpandDuration); // fade out the fab (rapidly) Animator fadeOutFab = ObjectAnimator.ofFloat(fab, View.ALPHA, 0f).setDuration(60); // play 'em all together with the material interpolator AnimatorSet show = new AnimatorSet(); show.setInterpolator(AnimUtils.getMaterialInterpolator(DesignerNewsStory.this)); show.playTogether(reveal, background, position, fadeOutFab); show.start(); }