0

I have a fragemnt with a recyclerView inside a viewPager of my MainActivity. When an item image on the recyclerView is clicked, it opens a new activity with the shared element transition between the images. Below is the the adapter for the recyclerView where i set up a onClickListener for the imageview inside the onBindViewHolder method...

    //Adapter
     holder.image.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    int position = holder.getAdapterPosition();

                    Intent intent = new Intent(mContext, NewActivity.class);

                    View sharedView = holder.Trendimage;

                    String transitionName = "transition";



            ActivityOptions transitionActivityOptions = ActivityOptions.makeSceneTransitionAnimation((MainActivity)mContext, sharedView, transitionName);

   mContext.startActivity(intent, transitionActivityOptions.toBundle());



                 mContext.startActivity(intent);

            }
        });

The only problem is that when I click on an item it loads the new activity but the shared element enter animation does not work, however when i press the back button whilst on the new activity it works.

I have all the transitions name setup with the correct views, and the animations are included in my App theme style as required...

Any help on this would be great

thank you

1 Answers1

0

You're calling startActivity() twice

David Liaw
  • 3,193
  • 2
  • 18
  • 28