I thought the system would reverse animations on the backstack when the back button is pressed when using fragments using the following code:
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.setCustomAnimations(R.anim.slide_in, R.anim.hyperspace_out);
ft.replace(R.id.viewContainer, new class(), "layout").addToBackStack(null).commit();
Replace the above with:
According to the android documentation for custom animation:
Change:
To:
and now the backstack animates - In reverse!!
Use the Correct animation I have used the following and its working like a charm
slide_in_left.xml
slide_in_right.xml
slide_out_left.xml
slide_out_right.xml
Then Use following while adding fragment
and it will worked 100%
in my case
would create perfect animation.
slide_in_right
slide_out_left