Reader small image

You're reading from  How to Build Android Apps with Kotlin

Product typeBook
Published inFeb 2021
Reading LevelIntermediate
PublisherPackt
ISBN-139781838984113
Edition1st Edition
Languages
Right arrow
Authors (4):
Alex Forrester
Alex Forrester
author image
Alex Forrester

Alex Forrester is an experienced software developer with more than 20 years of experience in mobile, web development, and content management systems. He has been working with Android for over 8 years, creating flagship apps for blue-chip companies across a broad range of industries at Sky, The Automobile Association, HSBC, The Discovery Channel, and O2. Alex lives in Hertfordshire with his wife and daughter. When he's not developing, he likes rugby and running in the Chiltern hills.
Read more about Alex Forrester

Eran Boudjnah
Eran Boudjnah
author image
Eran Boudjnah

Eran Boudjnah is a developer with over 20 years of experience in developing desktop applications, websites, interactive attractions, and mobile applications. He has been working with Android for about 7 years, developing apps and leading mobile teams for a wide range of clients, from start-ups (JustEat) to large-scale companies (Sky) and conglomerates. He is passionate about board games (with a modest collection of a few hundred games) and has a Transformers collection he's quite proud of. Eran lives in North London with Lea, his wife.
Read more about Eran Boudjnah

Alexandru Dumbravan
Alexandru Dumbravan
author image
Alexandru Dumbravan

Alexandru Dumbravan has been an Android Developer since 2011 and worked across a variety of Android applications which contained features such as messaging, voice calls, file management, and location. He continues to broaden his development skills while working in London for a popular fintech company.
Read more about Alexandru Dumbravan

Jomar Tigcal
Jomar Tigcal
author image
Jomar Tigcal

Jomar Tigcal is an Android developer with over 10 years of experience in mobile and software development. He worked on various stages of app development for small startups to large companies. Jomar has also given talks and conducted training and workshops on Android. In his free time, he likes running and reading. He lives in Vancouver, Canada with his wife Celine.
Read more about Jomar Tigcal

View More author details
Right arrow

4. Building App Navigation

Overview

In this chapter, you will build user-friendly app navigation through three primary patterns: bottom navigation, the navigation drawer, and tabbed navigation. Through guided theory and practice, you will learn how each of these patterns works so that users can easily access your app's content. This chapter will also focus on making the user aware of where they are in the app and which level of your app's hierarchy they can navigate to.

By the end of this chapter, you will know how to use these three primary navigation patterns and understand how they work with the app bar to support navigation.

Introduction

In the previous chapter, you explored fragments and the fragment lifecycle, and employed Jetpack navigation to simplify their use in your apps. In this chapter, you will learn how to add different types of navigation to your app while continuing to use Jetpack navigation. You will start off by learning about the navigation drawer, the earliest widely adopted navigational pattern used in Android apps, before exploring bottom navigation and tab navigation. You'll learn about the Android navigation user flow, how it is built around destinations, and how they govern navigation within the app. The difference between primary and secondary destinations will be explained, as well as which one of the three primary navigation patterns is more suitable, depending on your app's use case.

Let's get started with a navigation overview.

Bottom Navigation

Bottom navigation is used when there are a limited number of top-level destinations, and these can range from three to five primary destinations that are not related to each other. Each item on the bottom navigation bar displays an icon and an optional text label. This navigation allows quick access as the items are always available, no matter which secondary destination of the app the user navigates to.

Exercise 4.02: Adding Bottom Navigation to Your App

Create a new app in Android Studio named Bottom Navigation using the Empty Activity project template, leaving all the other defaults as they are. Do not use the Bottom Navigation Activity project template as we are going to use incremental steps to build the app. You are going to build a loyalty app that provides offers, rewards, and so on for customers who have signed up to use it. Bottom navigation is quite common for this kind of app because, typically, there will be limited top-level destinations. Let...

Tabbed Navigation

Tabbed navigation is mostly used when you want to display related items. It is common to have fixed tabs if there's only a few of them (typically between two and five tabs) and scrolling horizontal tabs if you have more than five tabs. They are used mostly for grouping destinations that are at the same hierarchical level.

This can be the primary navigation if the destinations are related. This might be the case if the app you developed is in a narrow or specific subject field where the primary destinations are related, such as a news app. More commonly, it is used with bottom navigation to present secondary navigation that's available within a primary destination. The following exercise demonstrates using tabbed navigation for displaying related items.

Exercise 4.03: Using Tabs for App Navigation

Create a new app in Android Studio with an empty activity named Tab Navigation. You are going to build a skeleton movies app that displays the genres...

Summary

This chapter has covered the most important navigation techniques you need to know about in order to create clear and consistent navigation in your apps. You started off by learning how to create an Android Studio project with a navigation drawer to connect navigation menu items to individual fragments using Jetpack navigation. You then progressed to actions within Jetpack navigation to navigate to other secondary destinations in your app within the navigation graph.

The next exercise then used bottom navigation to display primary navigation destinations that are always visible on the screen. We followed this by looking at tabbed navigation, where you learned how to display both fixed and scrollable tabs. For each different navigational pattern, you were shown when it might be more suitable to use, depending on the type of app you were building. We finished this chapter by building our own app using one or more of these navigational patterns and adding both primary and secondary...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
How to Build Android Apps with Kotlin
Published in: Feb 2021Publisher: PacktISBN-13: 9781838984113
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (4)

author image
Alex Forrester

Alex Forrester is an experienced software developer with more than 20 years of experience in mobile, web development, and content management systems. He has been working with Android for over 8 years, creating flagship apps for blue-chip companies across a broad range of industries at Sky, The Automobile Association, HSBC, The Discovery Channel, and O2. Alex lives in Hertfordshire with his wife and daughter. When he's not developing, he likes rugby and running in the Chiltern hills.
Read more about Alex Forrester

author image
Eran Boudjnah

Eran Boudjnah is a developer with over 20 years of experience in developing desktop applications, websites, interactive attractions, and mobile applications. He has been working with Android for about 7 years, developing apps and leading mobile teams for a wide range of clients, from start-ups (JustEat) to large-scale companies (Sky) and conglomerates. He is passionate about board games (with a modest collection of a few hundred games) and has a Transformers collection he's quite proud of. Eran lives in North London with Lea, his wife.
Read more about Eran Boudjnah

author image
Alexandru Dumbravan

Alexandru Dumbravan has been an Android Developer since 2011 and worked across a variety of Android applications which contained features such as messaging, voice calls, file management, and location. He continues to broaden his development skills while working in London for a popular fintech company.
Read more about Alexandru Dumbravan

author image
Jomar Tigcal

Jomar Tigcal is an Android developer with over 10 years of experience in mobile and software development. He worked on various stages of app development for small startups to large companies. Jomar has also given talks and conducted training and workshops on Android. In his free time, he likes running and reading. He lives in Vancouver, Canada with his wife Celine.
Read more about Jomar Tigcal