Android Development
Action Bar
Toolbar
UI Components
Mobile App Design

What is the difference between Action Bar and newly introduced Toolbar?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

The Action Bar and the Toolbar both occupy the top-app-bar role in classic Android views, but they are not the same abstraction. The Action Bar is a framework-managed app bar tied to the activity theme, while the Toolbar is a normal view that you place and control yourself.

What the Action Bar Is

The Action Bar was the original built-in top bar for Android activities. If your activity used a theme with an action bar, Android created it for you. You then configured it through the activity APIs.

That made simple screens easy, but it also limited layout freedom. Because the Action Bar belonged to the window and theme, you could customize it only within the boundaries the framework allowed.

Typical Action Bar code looked like this:

kotlin
supportActionBar?.title = "Inbox"
supportActionBar?.setDisplayHomeAsUpEnabled(true)

Useful, but not very flexible.

What the Toolbar Changed

Toolbar was introduced as a regular view container. It can live inside your layout XML like any other widget, which means you control its size, position, contents, and styling more directly.

A minimal example looks like this:

xml
1<androidx.appcompat.widget.Toolbar
2    android:id="@+id/toolbar"
3    android:layout_width="match_parent"
4    android:layout_height="wrap_content"
5    android:background="@color/teal_700"
6    android:minHeight="?attr/actionBarSize"
7    android:title="Inbox" />

And in your activity:

kotlin
1import android.os.Bundle
2import androidx.appcompat.app.AppCompatActivity
3import androidx.appcompat.widget.Toolbar
4
5class MainActivity : AppCompatActivity() {
6    override fun onCreate(savedInstanceState: Bundle?) {
7        super.onCreate(savedInstanceState)
8        setContentView(R.layout.activity_main)
9
10        val toolbar = findViewById<Toolbar>(R.id.toolbar)
11        setSupportActionBar(toolbar)
12    }
13}

After you call setSupportActionBar(toolbar), that toolbar becomes the activity's action bar implementation, but it is still your view.

Practical Differences

The main differences are architectural.

  • Action Bar is created by the theme; Toolbar is declared in your layout.
  • Action Bar is fixed in the standard top location; Toolbar can be placed anywhere a view can go.
  • Action Bar customization is limited; Toolbar can host custom child views, logos, search fields, and arbitrary content.
  • Action Bar feels tied to the activity; Toolbar composes naturally with fragments and custom layouts.

That flexibility is why Toolbar replaced the older model for most view-based Android apps.

Why Toolbar Became the Standard Choice

Modern Android UI often needs collapsing headers, scroll effects, branded layouts, and screen-specific top bars. Toolbar supports that because it behaves like a normal view. You can combine it with AppBarLayout, CollapsingToolbarLayout, or custom containers without fighting the window-level action bar model.

It also works better with Theme.AppCompat and Material-based apps that want consistent behavior across Android versions.

If you are maintaining older code, the Action Bar still works, but for new view-system code you should almost always start with Toolbar or MaterialToolbar.

Where MaterialToolbar Fits

MaterialToolbar is the Material Components version of Toolbar. It adds Material styling, theming support, and behavior aligned with current design guidance.

xml
1<com.google.android.material.appbar.MaterialToolbar
2    android:id="@+id/topBar"
3    android:layout_width="match_parent"
4    android:layout_height="wrap_content"
5    android:title="Orders" />

Conceptually, it is still in the Toolbar family: a real view that you own.

Common Pitfalls

A common mistake is forgetting to disable the theme-provided action bar before adding your own Toolbar. If you do not use a NoActionBar theme, you may end up with two app bars.

Another mistake is assuming Toolbar menus appear automatically. They still rely on the normal menu APIs, and the toolbar must be connected with setSupportActionBar if you want standard action-bar behavior.

Teams also mix terminology. After calling setSupportActionBar(toolbar), developers sometimes say they are “using the Action Bar,” even though the visible widget is a Toolbar acting as the support action bar. That is fine informally, but it hides the important architectural difference.

Summary

  • The Action Bar is framework-managed and theme-driven.
  • The Toolbar is a layout view that you can place and style directly.
  • Toolbar is more flexible for custom UI, fragments, and modern Material design.
  • Use a NoActionBar theme when supplying your own toolbar.
  • For new view-based Android code, choose Toolbar or MaterialToolbar over the old built-in Action Bar.

Course illustration
Course illustration

All Rights Reserved.