My app contains a view which consists of a ViewPager consisting of a handful of fragments. When you click on an item in one of these fragments, the expected behavior is for the shared element (in this case an image) to transition to the fragment which displays more information about the clicked content.
Here is a very simple video of what it should look like:
https://dl.dropboxusercontent.com/u/97787025/device-2015-06-03-114842.mp4
This is just using a Fragment->Fragment transition.
The problem arises when you place the starting fragment inside a ViewPager. I suspect this is because the ViewPager uses its parent fragment's child fragment manager, which is different than the fragment manager of the activity, which is handling the fragment transaction. Here is a video of what happens:
https://dl.dropboxusercontent.com/u/97787025/device-2015-06-03-120029.mp4
I'm pretty certain the issue here as I explained above is the child fragment manager vs the activity's fragment manager. Here is how I am making the transition:
SimpleFragment fragment = new SimpleFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.am_list_pane, fragment, fragment.getClass().getSimpleName());
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
TransitionSet enterTransition = new TransitionSet();
enterTransition.addTransition(new ChangeBounds());
enterTransition.addTransition(new ChangeClipBounds());
enterTransition.addTransition(new ChangeImageTransform());
enterTransition.addTransition(new ChangeTransform());
TransitionSet returnTransition = new TransitionSet();
returnTransition.addTransition(new ChangeBounds());
returnTransition.addTransition(new ChangeClipBounds());
returnTransition.addTransition(new ChangeImageTransform());
returnTransition.addTransition(new ChangeTransform());
fragment.setSharedElementEnterTransition(enterTransition);
fragment.setSharedElementReturnTransition(returnTransition);
transaction.addSharedElement(iv, iv.getTransitionName());
}
transaction.addToBackStack(fragment.getClass().getName());
transaction.commit();
This works fine when both fragments are managed by the activity's fragment manager, but when I load up a ViewPager like this:
ViewPager pager = (ViewPager) view.findViewById(R.id.pager);
pager.setAdapter(new Adapter(getChildFragmentManager()));
The children of the ViewPager are not being managed by the activity, and it doesn't work anymore.
Is this an oversight by the Android team? Is there any way to pull this off? Thanks.