I want to play hide animation on back press. I have working version of code for following packages:
android.support.v4.app.Fragment;
android.support.v4.app.FragmentTransaction;
code is following:
ft = getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_bottom, R.anim.slide_out_right);
Fragment fragment = new RegisterFragment();
ft.replace(R.id.sign_in_fragment, fragment);
ft.commit();
But now I am using androidx packages
androidx.fragment.app.FragmentTransaction;
In which case the back press animation does not work. it just removes fragment constantly. well code is little different but same:
ft = getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_top, R.anim.slide_out_top, R.anim.slide_out_top, R.anim.slide_out_top);
ft.replace(R.id.menu_fragment, menuFragment);
ft.addToBackStack(null);
ft.commit();
R.id.menu_fragment is empty and I do replace but add has same result. I found one answer which suggests to add tags on fragments but it does not work.
I think it's androidx package problem and I don't know with what to change. And project does not let me use just same old this package: android.support.v4.app.FragmentTransaction;
What to do or where do I make mistake? Thanks in advance.