When you open another activity and want to have a small picture (a view) inside a button animate to a big profile picture. That picture is called shared element.
- Create a
Scene
that holdsview
andtransitionName
. Pack them insideBundle
and send it to anotherActivity
. The destination view's xml must haveandroid:transitionName
attribute.
Intent intent = new Intent(context, AnotherActivity.class);
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(context, Pair.create(originView, "btnTransition"));
startActivity(intent, optionsCompat.toBundle());
<...
android:transitionName="btnTransition"
.../>