Shared Element Transition Not Working Between Parent and Child Fragments (Nested Fragments)

前端 未结 3 612
梦谈多话
梦谈多话 2020-12-19 07:35

In the Main Activity, I have BottomNavigationView where there are 3 different parent fragments. The parent fragment has recyclerview and on item cl

3条回答
  •  悲&欢浪女
    2020-12-19 07:56

    I'm not sure about the rest of your setup, but for Shared Element Transitions to work correctly, you need to add setReorderingAllowed(true) to your Fragment Transaction like this:

    FragmentTransaction transaction = manager.beginTransaction();
    transaction.add(R.id.child_fragment, newFragment, tag);
    transaction.addToBackStack(tag);
    transaction.addSharedElement(sharedView, sharedElementName);
    transaction.setReorderingAllowed(true); // Add this
    transaction.commit();
    

提交回复
热议问题