The effect I want to achieve is to overlay a new (new) fragment over the output (old) fragment, but when I replace the old fragment with a new fragment, the old one just disappears and the new fragment glides over the container that we see (container).
I donβt want to animate the old fragment, just keeping the old fragment as it is, and while it is visible, slide the new fragment over it.
Below is my code:
// First time adding fragment ie "oldFragemnt" FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.content_frame, oldFragment, "oldFragemnt"); ft.addToBackStack(null); ft.commit(); // while adding "newFragemnt" FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.setCustomAnimations(R.anim.new_slide_in_up,0,0,R.anim.new_slide_out_down); ft.replace(R.id.content_frame, newFragment, "newFragemnt"); ft.addToBackStack(null); ft.commit();
Guide me where I'm wrong My old fragment disappears and the new fragment unfolds.
source share