I implement fragments as below:
- Activity to hold parent fragment. Uses getSupportFragmentManager() to add Parent fragment.
- In parent fragment I use getChildFragmentManager() and transaction to replace childFragment.
- In childFragment I again call childFragment and so on....
- Everything work fine except shared transition.'
- If I use getFragmentManager() instead of getChildFragmentManager() then there is shared transition but then there is not concept of getChildFragmentManager().
The code sample looks like:
/*This code does not show animation*/
getChildFragmentManager()
.beginTransaction()
.addSharedElement(transitionView, ViewCompat.getTransitionName(transitionView))
.replace(R.id.fragment_container, categoryDetailChildFragment)
.addToBackStack(TAG)
.commit();
and the code that shows animation is:
getFragmentManager()
.beginTransaction()
.addSharedElement(transitionView, ViewCompat.getTransitionName(transitionView))
.replace(R.id.fragment_container, categoryDetailChildFragment)
.addToBackStack(TAG)
.commit();
Why there is no shared transition when getChildFragmentManager()? Please help anybody.