W końcu znalazłem odpowiedź.
Zmieniłem ViewPager z układem, aby zachować moje fragmenty (układ ramek). Następnie dodałem fragmenty do fragmentu Transakcji.
Dotykając elementu w BottomNavigation, bieżące ukrywanie fragmentów i nowe fragmenty są wyświetlane z animacją zanikania zdefiniowaną w fragmencie transakcji.
i to jest mój kod:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_page);
addFragmentsToManager();
}
private void addFragmentsToManager() {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
fragmentTransaction.add(R.id.flContent, tripFragment, tripFragment.getClass().getSimpleName());
fragmentTransaction.add(R.id.flContent, notificationFragment, notificationFragment.getClass().getSimpleName());
fragmentTransaction.add(R.id.flContent, searchFragment, searchFragment.getClass().getSimpleName());
fragmentTransaction.add(R.id.flContent, profileFragment, profileFragment.getClass().getSimpleName());
fragmentTransaction.hide(tripFragment);
fragmentTransaction.hide(notificationFragment);
fragmentTransaction.hide(searchFragment);
fragmentTransaction.hide(profileFragment);
fragmentTransaction.commit();
}
private void changeTab(int position) {
Fragment fragment;
switch (position) {
fragment = .....// get framgnet from position
}
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
fragmentTransaction.hide(prvFragment);
fragmentTransaction.show(fragment).commit();
prvFragment = fragment;
}
Tak, istnieją i nie mogę znaleźć sposobu na rozwiązanie problemu – FarshidABZ