Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save d4rkc0de/d289bf636f27723d2cacbcb26832ad54 to your computer and use it in GitHub Desktop.
Save d4rkc0de/d289bf636f27723d2cacbcb26832ad54 to your computer and use it in GitHub Desktop.
Shared element transition among fragments that belong to different activities
Inside the first Activity :
Pair[] pairs = new Pair[1];
pairs[0] = new Pair(thumbnailImage, "THUMBNAIL_IMAGE");
public static void transitionExpand(Activity activity, Intent intent, Pair<View, String>[] sharedElements) {
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElements);
ActivityCompat.startActivity(activity, intent, options.toBundle());
}
call it this way : transitionExpand(this,new Intent(this, NewActivity.class),pairs);
Inside the fragment of the second activity : ViewCompat.setTransitionName(view.findViewById(R.id.picture), "cameraButton");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment