Effect what I want to achieve is to overlay enter (new) fragment above the exit(old) fragment, but when I am replacing old fragment by new fragment,the old one just vanishes and new fragment slides up the container, which is visible (container).
I don't want to animate the old fragment, just keeping old fragment as it is and while it is visible slide up the new fragment above it.
Below is my code :
// First time adding fragment i.e. "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 am going wrong. My old fragment is vanishing while the new fragment is sliding up.
You can try to replace the replace() with add() to achieve the effect you want. Hope this will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With