

You can directly use following code in your project – activity_main.xml I combined the above whole code and created an example. Use the following code for NavigationView – Ĭomplete Example of Navigation Drawer in android We can manage it according to us by giving the padding, margin and other styles.

NavigationView holds the navigation drawer elements like headerLayout and navigation items. And add the icon from the drawable folder. I created only three items you can create here as much as you want. These items will be listed below the header layout in drawerLayout in android.įirst of all create the menu directory in res using the way – res -> right click -> new – > Android Resource Directory and name it menu.Īfter that right click on menu directory – > new -> Menu Resource File -> give a name -> Choose menu as Directory name from dropdown. To show the items in the navigation drawer we have to create a list of items. After creating this layout copy and paste the following code. And mouse right click – > new -> Layout Resource File and give a name as you want. You can create it in app – > res -> layout. So this is custom you can create it according to you and set the data. Generally it contains a circular image, name and email id.

Header layout is not any specific layout, this is just a simple layout which is shown in above image. To create FrameLayout use the following code in your project. So we have to create the screen of the fragment type, which we want to load in this layout by clicking on navigation drawer items. Generally it loads fragments instead of activity. To use the toolbar height use the following component in the toolbar.įrameLayout in android is used to load multiple screens in a single place. By clicking on the toggle icon, the drawer will open from the left side. It can be left side or right side according to us, we are creating it from the left side. Navigation drawer toggle in android takes place on it. Toolbar is fixed at the top of the screen.
