3

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 onItemClickof 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.

Shivani Gupta
  • 271
  • 3
  • 12

1 Answers1

-1

I can understand your problem. Basically what is happening is that, you are only sharing the 2 Views you have mentioned. But the Status Bar on the Top, the Navigation Bar on the Bottom (and maybe others, in your case)do not get shared. So it seems like a blink.

You can see this post, see if it helps.

https://stackoverflow.com/a/26748694/2346980

Community
  • 1
  • 1
Keshav
  • 577
  • 3
  • 10