Shared Element Transition into a View in a RecyclerView, possible?
Asked Answered
E

2

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!

Extractive answered 24/9, 2015 at 3:19 Comment(1)
Any findings? Wonder the sameBohun
P
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

Perfidy answered 14/4, 2016 at 10:35 Comment(0)
S
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();
            }
        });
Saidel answered 23/5, 2016 at 12:3 Comment(0)
P
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

Perfidy answered 14/4, 2016 at 10:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.