ActionBar in Android with Example (original) (raw)

Last Updated : 23 Jul, 2025

In Android applications, **ActionBar is the element present at the top of the activity screen. It is a salient feature of a mobile application that has a consistent presence over all its activities. It provides a visual structure to the app and contains some of the frequently used elements for the users. Android ActionBar was launched by **Google in 2013 with the release of **Android 3.0(API 11). Before that, the name of this top most visual element was **AppBar. AppBar contains only the name of the application or current activity. It was not very much useful for the users and developers also have negligible option to customize it.

Google announced a **support library along with the introduction of ActionBar. This library is a part of **AppCompat and its purpose is to provide backward compatibility for older versions of Android and to support tabbed interfaces. All applications that use the default theme provided by the Android(Theme.AppCompat.Light.DarkActionBar), contains an ActionBar by default. However, developers can customize it in several ways depending upon their needs.

**Components included in the ActionBar are:

Designing a Custom ActionBar

The following example demonstrates the steps involved in creating a custom Action Bar for the MainActivity of an application. All important aspects of visual elements like icon, title, subtitle, action buttons, and overflow menu will be covered.

**Note: Following steps are performed on **Android Studio Ladybug 2024.2.2

**Step 1: Enable Action Bar

In the new versions of Android, the Action bar is disabled explicitly by default. To enable, navigate to **app > res > values > themes.xml. Remove the "NoActionBar" text from the parent style. Follow the below code, to understand clearly.

**Before

<style name="Theme.Demo" parent="Base.Theme.Demo" />

`

**Output:

action-bar-colored

**Run on Emulator:

**Advantages of ActionBar

**Disadvantages of ActionBar

**Note: To resolve all the problems related to ActionBar, Google introduced **ToolBar along with the release of **API 21(Android Lollipop). To know more, refer to **ToolBar in Android with Example