

- #Android navigation drawer set icon android#
- #Android navigation drawer set icon code#
- #Android navigation drawer set icon download#
In above code snippet DrawerLayout is the root view of our Layout in which we have other layouts and content.įrameLayout is used to hold the page content shown through different fragments. Inside this DrawerLayout add one view that contains the main content of the screen means primary layout that displays when the drawer is hidden and other view that contains the contents for the navigation drawer. Drawer position and layout is controlled by using layout_gravity attribute on child views corresponding to which side of view we want the drawer to emerge from like left to right.įor adding a Navigation Drawer, declare your UI(user interface) with a DrawerLayout object as the root(parent) view of your layout. In Android, DrawerLayout acts as top level container for window content that allows for interactive “drawer” views to be pulled out from one or both vertical edges of the window. In Navigation Drawer we combine NavigationView and DrawerLayout to achieve the desired output.
#Android navigation drawer set icon android#
But now Android itself officially introduced sliding panel menu by introducing a newer concept called Navigation Drawer. This kind of UI was done by using third party libraries where a ListView and swiping gestures used to achieve this type of UI. We might have noticed that lot of our Android Applications introduced a sliding panel menu for navigating between major modules of our application. 7 Navigation Drawer Example in Android Studio:.6 Important Methods Of Navigation View:.In the Navigation Menu, there are some social links like Facebook, G+, Twitter, YouTube, and Github. I will handle the menu click items in the following lines of code, public boolean onNavigationItemSelected(MenuItem item) Navigation Menu item - WebViewFragment I initialized the NavigationView using the following couple of lines, NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view) tNavigationItemSelectedListener(this) So now the NaviginationMenu is completed, now I will link this menu item clicks to its related fragment. The social network icons I used are from the other icons are default android icons.
#Android navigation drawer set icon download#
In the above screenshots, you can see an icon beside each menu item, that can be set using the android icon attribute these icons are either android default images or you can download any icon of your wish and use them. I also gave a title to the sub menu as 'Social'. Item which is the single menu item, we can divide/separate the menu by creating an another menu as the sub-child of item element. menu which is the root element and it can have sub child's/sub elements like item and group. If you look at the above code, I created a menu using menu, item, and group. Open the activity_main_drawer.xml file and place the following code in it. In the above snippet in the last line which says that the menu for this is located at menu directory in the res folder. If you open activity_main.xml file at app/res/layout directory, you can see the code for NavigationMenu. First, I will finish the navigation menu layout. I will go step by step and tell you about the application we are going to build. Here I will use that and extend it to leverage the code Android Studio gave us by default :D Navigation Menu Basically, it has the navigation menu, icons, header and handling the menu item clicks and all that stuff. So after Android Studio does its thing and eventually show you ‘Gradle build finished’ (:P just kidding, if you have a good configuration, everything will load fine), you can see some layout files and an activity file (MainActivity.java) with some code written in it.
