Following is simple code to animate fragment when switching between fragment
CategoryFragment newFragment = new CategoryFragment(); Bundle args = new Bundle(); newFragment.setArguments(args); FragmentTransaction transaction = getSupportFragmentManager() .beginTransaction(); // Replace whatever is in the fragment_container view with this // fragment, // and add the transaction to the back stack so the user can // navigate back transaction.setCustomAnimations(R.anim.left_to_right, R.anim.right_to_left); transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit();
Put Following xml to res/anim folder
left_to_right.xml
left_to_right.xml