9

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!

1
  • Any findings? Wonder the same
    – Sunkas
    Oct 7, 2015 at 11:43

2 Answers 2

4

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();
            }
        });
0

According to my investigation this is not possible. Before a shared element transition can create its animation, it must first capture each shared element’s start and end state—namely its position, size, and appearance in both the calling and called Activities/Fragments. With this information, the transition can determine how each shared element view should animate into place. (via http://www.androiddesignpatterns.com/2015/01/activity-fragment-shared-element-transitions-in-depth-part3a.html)

Official documentation declares limitations:

Classes that extend AdapterView, such as ListView, manage their child views in ways that are incompatible with the transitions framework. If you try to animate a view based on AdapterView, the device display may hang.

http://developer.android.com/training/transitions/overview.html#Limitations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.