先上效果图
其实实现起来非常简单,比如现在有两个Activity:GridActivity跳转DetailActivity,首先在GridActivity跳转DetailActivity的代码上加入ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, imageView, "ABC");
,ABC随意起了一个名字。
Intent intent = new Intent(activity, DetailActivity.class);intent.putExtra("IMGURL", imgs.get(position));ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, imageView, "ABC");activity.startActivity(intent, options.toBundle());
然后在DetailActivity中加入ViewCompat.setTransitionName(imageView, "ABC");
就轻松实现了。