From the course: Android Development Essential Training: App Architecture with Kotlin

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Add a navigation toggle button

Add a navigation toggle button - Android Tutorial

From the course: Android Development Essential Training: App Architecture with Kotlin

Start my 1-month free trial

Add a navigation toggle button

- [Instructor] I want to display a toggle button in the activities top corner that the user can press to open the navigation drawer. My first step is to refactor my main activity layout and wrap the the constraint layout in another set of components. Let's take a look at the file activity_dice.xml. This file's root element is something called a coordinator layout. It contains an app bar layout which contains a toolbar. These components are designed to work with the navigation drawer so I'm going to select and copy everything starting from the coordinator layout to right above the include statement. And then I'll come back to activity_main.xml and I'll paste it right here before the constraint layout. Then I'll go down to the bottom of the file and I'll type a less-than character and a slash, and android studio auto-completes that to the end tag for the coordinator layout. The constraint layout is no longer the root element so I don't need these name space declarations. And, then I'll…

Contents