Configuring the App Bar

Each of our apps’ activities has had this green bar across the top:

Activity, Highlighting Some Sort of Bar
Activity, Highlighting Some Sort of Bar

To date, all it has done is show our title (app_name string resource). However, there is more that we can do with this bar, and we will explore some of that in this chapter.

Our first problem, though, in deciding what this thing is called.

So. Many. Bars.

Many aspects of Android have changed over the years. For example, few Android 1.x/2.x apps had this sort of bar at the top.

Sometimes, when Android changes, Google simply adds some new capability or design feature, and that’s it. Sometimes, Google does one thing, then changes course and replaces it with something else. And, on occasion, Google makes so many changes that the result is quite a mess.

This bar is quite a mess.

Part of it is simply the name. Depending on who you ask, this bar could be referred to as:

Action Bar

In the beginning, we referred to this as the “action bar”. Activity and other classes had support for showing an action bar and doing things with it, such as dynamically changing the title shown in the bar.

Nowadays, “action bar” is more of a role than an actual thing. We can opt into using the action bar APIs, or we can achieve similar functionality without them.

Toolbar

The “action bar” terminology dominated Android 3.x and 4.x.

Android 5.0 debuted a Toolbar class. Initially, it was thought that the Toolbar was simply a bit of refactoring, giving us a widget that looked and worked like the action bar. The nice thing about Toolbar was that you could put one anywhere you wanted in your UI, making it simpler to add dedicated toolbars, such as for a rich-text editor.

Over time, Toolbar became the stock implementation of this sort of top-of-the-activity bar.

From a terminology standpoint, we have used “toolbar” as a descriptive term for quite some time, as “toolbar” is a widely-used term in desktop apps. A desktop app toolbar served a very similar role to the action bar in Android, and then the Toolbar in Android. So, you might see references to “toolbar buttons” in Android, which really refer to that sort of UI pattern, regardless of whether those buttons appear on an actual Toolbar or not.

App Bar

In 2015, Google debuted “Material Design”. This is Google’s “design language” for mobile, Web, and desktop apps. It provides Google’s recommendations for what things should look and work like.

In Material Design, this bar is called the app bar, because apparently Google likes coming up with new names for this.

The Material Design team has also created “Material Components for Android”, which is a library that implements many of the UI patterns seen in Material Design that go beyond what modern versions of Android support directly. There, they have classes like AppBarLayout and CollapsingToolbarLayout, for trying to implement some of the specific Material Design recommendations regarding app bars, such as how they behave with respect to scrolling content in an activity.

Bars and This Book

From this point forward, the book will tend to use:

(the book will use few profanities, no matter how appropriate they may be for aspects of Android app development)

Bars Beyond These Bars

There are other bars in the Android UI that are unrelated to the app bar:


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.