Animating fragments and the back stack
Solution 1:
I use this:
ft.setCustomAnimations(R.anim.slide_in, R.anim.hyperspace_out, R.anim.hyperspace_in, R.anim.slide_out);
and the transitions work in reverse when the back button is presses.
Solution 2:
The bug was fixed in the 3.2 release with the addition of the following new api:
http://developer.android.com/reference/android/app/FragmentTransaction.html#setCustomAnimations(int, int, int, int)
It's to be noted that it has not yet been back-ported to the compatibility library (as mentioned in the bug report).
Solution 3:
It's a bug, look at bug report 15623. One of the Android project members commented that the fix was too late for release 3.1 but it should make it into the next release.
The same member goes on to say that...
The problem is that the same animations are run on a pop operation as were run to put the fragments in their current places. For example, in the sliding example above, on a forward operation (pushing the old fragment onto the stack and moving the new fragment into view), we slide the old fragment out from the center to the left and slide the new fragment in from the right to the center. When the stack is popped, these same animations are run: the most recent fragment is animated 'out' by sliding it in from the right to the center (after which it disappears, since it's being removed). The old fragment is popped off the stack and animated from teh center to the left ... right off the screen.