of drawables so we can reduce the amount of resources in our application. Also we will see cases where a drawable could easily replace views, making our app more clean and faster. Objective
ImageView ivMovieCover) { Intent intent = MovieDetailActivity.newIntent(MainActivity.this, movie); ivMovieCover.setTransitionName("movie_cover"); startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(MainActivity.this, ivMovieCover, "movie_cover").toBundle()); } })); We need access to the element that will be shared MoviesActivity.java
super.onCreate(savedInstanceState); setContentView(R.layout.activity_movie_detail); ButterKnife.bind(this); movie = (Movie) getIntent().getSerializableExtra(EXTRA_MOVIE); toolbar.setBackgroundResource(movie.resImageBanner); ivMovieCover.setImageResource(movie.resImageCover); tvMovieTitle.setText(movie.name); tvMovieSubtitle.setText(movie.subtitle); tvMovieDescription.setText(movie.description); ivMovieCover.setTransitionName("movie_cover"); } Set transition name in the next activity MovieDetailActivity.java
super.onCreate(savedInstanceState); setContentView(R.layout.activity_movie_detail); ButterKnife.bind(this); movie = (Movie) getIntent().getSerializableExtra(EXTRA_MOVIE); toolbar.setBackgroundResource(movie.resImageBanner); ivMovieCover.setImageResource(movie.resImageCover); tvMovieTitle.setText(movie.name); tvMovieSubtitle.setText(movie.subtitle); tvMovieDescription.setText(movie.description); ivMovieCover.setTransitionName("movie_cover"); } Set transition name in the next activity MovieDetailActivity.java
{ if (getVisibility() != View.VISIBLE) { return; } if (isTransitionGroup()) { transitioningViews.add(this); } else { int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); child.captureTransitioningViews(transitioningViews); } } } Before the transition starts, the framework constructs the set of transitioning views by performing a recursive search on the Activity window’s (or Fragment’s) entire view hierarchy.
{ if (getVisibility() != View.VISIBLE) { return; } if (isTransitionGroup()) { transitioningViews.add(this); } else { int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); child.captureTransitioningViews(transitioningViews); } } } Before the transition starts, the framework constructs the set of transitioning views by performing a recursive search on the Activity window’s (or Fragment’s) entire view hierarchy.
{ if (getVisibility() != View.VISIBLE) { return; } if (isTransitionGroup()) { transitioningViews.add(this); } else { int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); child.captureTransitioningViews(transitioningViews); } } } Before the transition starts, the framework constructs the set of transitioning views by performing a recursive search on the Activity window’s (or Fragment’s) entire view hierarchy.
{ if (getVisibility() != View.VISIBLE) { return; } if (isTransitionGroup()) { transitioningViews.add(this); } else { int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); child.captureTransitioningViews(transitioningViews); } } } Before the transition starts, the framework constructs the set of transitioning views by performing a recursive search on the Activity window’s (or Fragment’s) entire view hierarchy.