Calling a fragment with this method

public void showFragment(Fragment fragment){ getSupportFragmentManager() .beginTransaction() .addToBackStack(null) .replace(R.id.layout1, fragment) .commit(); } 

enter image description here

enter image description here

As a result, I get the imposition of a fragment on a fragment, but not a replacement

  • The original fragment you have, by chance, is not registered in xml? Right in the markup activit? - Yuriy SPb
  • The fragment is connected via the viewPager, and that in turn is registered in the activation markup - kalugin1912
  • Those. Do you want to display another fragment on top of a fragment? If yes, then do not even try to try to do so, but immediately instead of a fragment, start activating with it. Otherwise - spend a lot of time for nothing. - Yuriy SPb

0