The new Shared Element Transitions works when i use Fragment \'replace\' but i can\'t seem to make it work fragment \'add\'. I use the same container in bo
It will not animate because the old fragment is still present. For adding you need to hide the previous fragment. Here is the example
For pushing:
fragmentTransaction.add(R.id.content, fragment);
if (fragments.size() > 0) {
UIBaseFragment lastElement = fragments.lastElement();
fragmentTransaction.hide(lastElement);
}
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
fragments.push(fragment);
Then pop in this way
final FragmentManager manager = getChildFragmentManager();
manager.popBackStack();
fragments.pop();