6

So here's the problem: I have a Main Activity and within it lies a fragment that contains a RecyclerView, the shared element is in the viewholder of the RecyclerView. When you click this shared element, it starts a new activity with a shared element transition. The first time you start it, the shared element will blink and if you return the animation plays nicely. If you start the same element as before a second time, the animation will also play nicely. It is just the first time that it blinks.

This is the callback from the RecyclerView's adapter, I pass the shared View and start the other activity. This code is in the fragment that I mention above.

@Override
public void onClick(int arrayPosition, int position, View view) {
    Movie movie = mMovieLists.get(arrayPosition).getMovieList().get(position);
    Intent intent = new Intent(getActivity(), MovieDetailActivity.class);
    intent.putExtra(MovieDetailActivity.MOVIE_ID_INTENT, movie.getmId());
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), view, getString(R.string.movie_poster_trans));
    startActivity(intent, options.toBundle());
}
ConfusedCoder
  • 337
  • 2
  • 3
  • 12

0 Answers0