- 我是用google自带的 Bottom navigation activirty, 然后我在home里面加了一个button用replace的方法跳转到新的fragment, 在用底部导航回去结果还在背后
这是main activity的方法
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications)
.build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(navView, navController);
这是跳转我用的方法
public void replaceFragment(Fragment newFragment){
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.nav_host_fragment,newFragment).commit();
}