Difference Between AppBar, ActionBar, and Toolbar in Android
AppBar is a design element in an application’s activity that has a significant role. Its appearance gives a unique identity to the application. Moreover, it displays the title of the current activity that facilitates users to know their location in the application. To give a consistent look to an application, developers use AppBar. Prior to Android 3.0(Honeycomb), the user interactive elements like any option or action are placed inside the Menu button located in the AppBar. Components included in the AppBar are:
AppBar in an application:
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:
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:
|It is a dedicated space located at top of an activity that indicates the app title or location of a user in the app.
|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 used in Android devices running on OS version older than 3.0(Honeycomb).
|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).
|Its position is fixed i.e., at the top of an application screen.
|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.
|Android system allows the presence of only one AppBar in an activity.
|There can be only one ActionBar in an activity. Developers have the choice to show or hide the ActionBar.
|Multiple Toolbar elements having a completely different appearance and the behavior can be defined within a single activity. A Toolbar can also be used as an ActionBar.
|Its prime purpose is to provide identity to the application. Further, it includes a Menu button that is used by developers to display relevant options/actions to the user.
|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.
|With the increase in demand for devices powered with the latest Android versions, developers migrated their design from the Menu button to ActionBar.
|Features were added gradually, at the different API levels(15, 17, and 19). Thus it does not provide backward compatibility.
|Uses material theme design and provides backward compatibility up to API 7(Android 2.1).
Share your thoughts in the comments
Please Login to comment...