Skip to content
Related Articles

Related Articles

Difference Between ActionBar and Toolbar in Android
  • Last Updated : 23 Feb, 2021

ActionBar

ActionBar is the element present at the top of the activity screen. It is a salient feature of an android 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. 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 that can be included in the ActionBar are:

  • Navigation control button/drawer
  • App icon
  • Title and Subtitle
  • Action button
  • Action overflow menu

ActionBar in an application:

Toolbar

The Toolbar is a kind of ViewGroup that can be placed in the XML layouts of an activity. It was introduced by the Google Android team during the release of Android Lollipop(API 21). The Toolbar is basically the advanced successor of the ActionBar. It is much more flexible and customizable in terms of appearance and functionality. Unlike ActionBar, its position is not hardcoded i.e., not at the top of an activity. Developers can place it anywhere in the activity according to the need just like any other View in android. Toolbar use material design theme features of Android and thus it provides backward compatibility up to API 7(Android 2.1). Features supported by the Toolbar are much more focused and customizable than the ActionBar. Following are the components that can be added to a Toolbar:

  • A navigation button/drawer or an Up button
  • Brand logo/App icon
  • Title and Subtitle
  • ActionMenu items
  • Multiple custom views such as TextView, ImageView, etc.

Both ActionBar(at the top) and Toolbar in an application:



Difference Table

ActionBar

Toolbar

It is a dedicated navigation or control element present at top of each screen of the application.It is a ViewGroup that can be placed anywhere in the activity layout.
It was released along with Android 3.0 (API -11) as the successor of AppBar.  Introduced in Material design with the release of Android 5.0 i.e., lollipop(API – 21).
It is a part of the activity’s opaque window decor, thus its position is hardcoded.It is the generalized form of ActionBar that can be placed at any arbitrary level within the Component Tree hierarchy of an activity.  
There can be only one ActionBar in an activity. Developers have the choice to show or hide the ActionBar.Multiple Toolbar element having a completely different appearance and behavior can be defined within a single activity. A Toolbar can also be used as an ActionBar.
Behaves as a regular AppBar but provides scope for customization. Developers can add application logo/icon, action menu items, overflow menu, etc.Fewer lines of code are needed to make the same customization in Toolbar that is possible in ActionBar. Moreover, Toolbar provides more flexibility and control to the developers by which they can animate the elements or can apply reaction to scroll events.
Google introduced new features in ActionBar gradually. During the release of API 15, 17, and 19 several new features were added to the ActionBar.All features and functionalities were released during the launch of API 21 with the addition of material theme design
Features added at the different API level does not provide backward compatibility. Provides backward compatibility up to API 7(Android 2.1).
Want a more fast-paced & competitive environment to learn the fundamentals of Android?
Click here to head to a guide uniquely curated by our experts with the aim to make you industry ready in no time!
My Personal Notes arrow_drop_up
Recommended Articles
Page :