A header layout can make a navigation drawer more visually interesting. In this video, create a header layout and display it at the top of an existing drawer component.
- [Male Instructor] You can add a visual header … to the top of a navigation drawer … To add the header, first I'm going to need … some dimension resources. … I'll add these to an existing file in my values directory … called dimens.xml. … First I'll create a new dimension called header dice margin. … And I'll set it to a value of eight DP. … Then I'll create a second dimension … and this one will be named header dice size … and its value will be 30 DP. … These will be used to size and lay out a set … of image view components that show die images. … Next, I'll create a new layout file. … A header for a drawer is simply another layout. … I'll set the name of the new layout … to main nav header … and I'll accept the root element of linear layout. … You could use a constraint layout … to do what I'm about to do, … but I'm just going to show an alternative approach. … The header's width should be set to match parent. … But the height should be set to a specific height. … And I'll set it to a value of 176 DP. …
Looking for study partners?Join the Associate Android Developer Exam study group
The Android app architecture constantly evolves. The introduction of the Kotlin programming language, new form factors such as Chromebooks, and reusable architecture components have made it faster and easier than ever to build high-quality Android apps. It is imperative that developers understand what the latest tools and recommendations are and how to use them to build out their applications. In this course, instructor David Gassner explains how to build an Android app that uses Kotlin instead of Java, add navigation functionality, and leverage the most useful architecture components such as LifecycleObserver, ViewModel, and LiveData, to create apps that are robust and easy to maintain over time.
- Handling lifecycle events
- Handling view events
- Updating display from new data
- Adding ViewModels to activities
- Subscribing to changes in LiveData values
- Adding a new launcher activity
- Starting activities with explicit intents
- Sharing data with implicit intents
- Adding a navigation drawer
- Adding a header to a navigation drawer
- Handling navigating drawer menu events