![]() |
VOOZH | about |
Navigation Drawer or Slider Drawer is a UI pattern, used in Mobile Applications and Websites. It is used to provide easy access to different features or parts of an app or website.
It is usually accessed by tapping on the hamburger menu icon (3 horizontal lines), present in the top-left or top-right corner of the screen, or swiping from the left edge of the screen.
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.
dependencies {
...
implementation ("com.google.android.material:material:1.12.0")
}
Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. Comments are added inside the code to understand the code in more detail.
activity_main.xml:
Navigate to the app > res > layout > nav_header.xml and add the below code to that file. Below is the code for the nav_header.xml file.
nav_header.xml:
Navigate to the app > res > menu > nav_menu.xml and add the below code to that file. Make sure to add a relatable menu icon in the drawable file. Below is the code for the nav_menu.xml file.
nav_menu.xml:
Go to the MainActivity file and refer to the following code. Below is the code for the MainActivity file. Comments are added inside the code to understand the code in more detail.
MainActivity File:
Navigate app > res > values > strings.xml and add the following values
<resources>
...
<string name="open_drawer">Open navigation drawer</string>
<string name="close_drawer">Close navigation drawer</string>
</resources>