Ripple effect not working with shared element transition and RecyclerView

Viewed 1543

I have a shared element transition when a `RecyclerView item click starts a detail Activity, but the ripple effect on the item click is never visible

Start Activity with shared element transition

Intent intent = IntentUtils.createDetailsIntent(InspectionListFragment.this.getContext(), record);
Bundle options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
                  view, getString(R.string.transition_element)).toBundle();
getActivity().startActivity(intent, options);

I noticed this log message

D/OpenGLRenderer: endAllStagingAnimators on 0x95e86600 (RippleDrawable) with handle 0xaa6c2760

If I remove the transition, the ripple works (and I don't see this message).

Delay Activity start using Handler

If I use a Handler with postDelayed to start the Activity, the results were mixed. I see the ripple, but the transition is not as smooth:

    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            Intent intent = IntentUtils.createDetailsIntent(InspectionListFragment.this.getContext(), record);
            Bundle options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
                  view, getString(R.string.transition_element)).toBundle();
            getActivity().startActivity(intent, options);
        }
    }, 200);

Using ListView

Note that using a ListView with the same item layout and makeSceneTransitionAnimation works fine. Unfortunately this is not suitable.

The item layout

<LinearLayout
    android:background="?android:attr/selectableItemBackground"
    android:clickable="true"
    android:focusable="true"
1 Answers
Related