I've followed instructions from dmanargias answer here: Android Fragments and animation
The animations themselves work, however the initial animation when adding a fragment is doing something strange. The initial fragment appears to be replaced with the new fragment before the animation is started.
e.g. One would expect an animation of A <- B (B sliding from right to cover A)
However as soon as the action starts A instantly becomes B and you get an animation of B <- B.
When popping the stack you get a correct animation of A -> B (B sliding away revealing A)
This is the code that adds a fragment:
CategoryFragment newFragment = CategoryFragment.newInstance();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit);
fragmentTransaction.replace(R.id.fragment, newFragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
Any ideas why this would happen and if there's a way to fix it?