Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shared Element Transition into a View in a RecyclerView, possible?

In view of normal Lollipop transition of Activity having shared elements, e.g. https://github.com/codepath/android_guides/wiki/Shared-Element-Activity-Transition, it is quite common one is transitioning from a View from a Recycler View into a normal View of a targeted Activity.

However, in the event of the targeted view, is also in a viewholder of a recyclerView, is there a way to make that possible (i.e. provide the targeted view to the ActivityOptionsCompat)?

Thanks!

like image 373
Elye Avatar asked Sep 24 '15 03:09

Elye


1 Answers

It is absolutely possible. Do do that you have to follow these steps:

  1. Postpone the transition in your target activity with supportPostponeEnterTransition().
  2. Set the adapter to the RecyclerView.
  3. Start the postponed transition after the RecyclerView has drawn the items.

Step 3 usually works with this:

recyclerview.post(new Runnable() {
            @Override
            public void run() {
                supportStartPostponedEnterTransition();
            }
        });
like image 170
Thorben Avatar answered Oct 19 '22 13:10

Thorben