I am having two activities,out which first activity contain a recycle view in fragment which is added on the first activity and second activity contain a toolbar in collapsing toolbar layout,i have created a shared element transition between this two activities when a user click on a any Recycle view item which contains a image which i want to use as shared element to the second activity's toolbar image.i have set the transition like this.
First Activity
ChangeBounds changebound=new ChangeBounds();
changebound.setDuration(500);
getWindow().setSharedElementExitTransition(changebound);
Second Activity
ChangeBounds changebound=new ChangeBounds();
changebound.setDuration(500);
getWindow().setSharedElementEnterTransition(changebound);
I am Staring Second Activity from Recycler view onItemClick
of the first activity like this
Pair<View, String> imagePair=Pair.create(itemView.findViewById(R.id.imgChannelImage), activity.getResources().getString(R.string.channel_name));
Bundle mBundle = new Bundle();
mBundle.putInt("Position", getLayoutPosition());
mBundle.putString("ChannelName", "One Direction " +getLayoutPosition());
Intent i = new Intent(activity, ProChannelPageActivity.class);
i.putExtras(mBundle);
ActivityOptionsCompat options = ActivityOptionsCompat.
makeSceneTransitionAnimation(context,imagePair);
activity.startActivity(i, options.toBundle());
I am able to have shared element transition between this two.but the problem is having a background glitch i.e we able to see the first activity background for few fraction while image view moving from one activity to another.