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:
- **App Icon: Display the branding logo/icon of the application.
- **View Controls: Section that displays the name of the application or current activity. Developers can also include spinner or tabbed navigation for switching between views.
- **Action Button: Contains some important actions/elements of the app that may be required to the users frequently.
- **Action Overflow: Include other actions that will be displayed as a menu.
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:

**Run on Emulator:
**Advantages of ActionBar
- Provides a customized area to design the identity of an app
- Specify the location of the user in the app by displaying the title of the current Activity.
- Provides access to important and frequently used actions
- Support tabs and a drop-down list for view switching and navigation.
**Disadvantages of ActionBar
- All features of the ActionaBar are not introduced at once but were introduced with the release of different API levels such as API 15, 17, and 19.
- The ActionBar behaves differently when it runs on different API levels.
- The features that were introduced with a particular API does not provide backward compatibility.
**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