Hello!

The problem: there is MainActivity.xml, which contains the container for the fragments and DrawerLayout. Different fragments are loaded into the container for fragments, some of them need NavigationDrawer, and some are not needed, but with such markup on any fragment you can open the side menu with the left swipe, how to mark up correctly in this case? Make another container in which to load fragments for which you do not need NavigationDrawer?

scheme

  • one
    at your NavigationDrawer you can call setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED) and the icon in INVISIBLE - ermak0ff
  • @ ermak0ff as an option, but it will be a crutch) - Kalyashov Gregory
  • Yes, a crutch in part, but something I did not see the finished solution out of the box)) - ermak0ff
  • In my opinion, the solution proposed by @ ermak0ff is the most logical. - post_zeew

2 answers 2

Look: you made an activation from the side menu, so that the fragments in this activation would have the same side menu. The system has a fragment that does not need this sidebar. Conclusion: this fragment should not be a fragment, but should be a new activation.

    Make an activation that has only a fragment container. And already in the markup of the fragments you need, make DrawerLayout with NavigationView . This is the easiest option.

    • The easiest, but then you have to do the same thing in each fragment, this is not very good) - Kalyashov Gregory
    • And who prevents you from creating a basic fragment, with all common actions and inheriting all fragments from NavigationView from it - pavel163
    • yes, but I meant that in the markup for each fragment you need to add DrawerLayout - Kalyashov Gregory
    • And what's stopping you to do through the tag <include> - pavel163
    • And it is better to create one layout with markup with NavigationView. And in it already in the base fragment inflate the necessary layout - pavel163