How do I change the android actionbar title and icon
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In older Android apps people say “ActionBar,” but in modern apps the real answer is usually “Toolbar configured as the support action bar.” You can still change the title and icon, but the exact API depends on whether you mean the app title, the logo, or the navigation icon.
That distinction matters because many code samples mix them together. The title text, app logo, launcher icon, and back arrow are different UI elements.
Change the Title Programmatically
If your activity uses AppCompat:
Java version:
This changes the action bar title for the current activity.
Set the Default Title in the Manifest
If you want the title to be static for an activity, set it in the manifest:
This is a good choice when the title does not change at runtime.
Change the Logo or Icon
What many people call the “action bar icon” is often the logo area to the left of the title. To show a custom logo:
This does not change the launcher icon of the app. It changes the icon area inside the bar itself.
If you are using a Toolbar, you can also set the logo directly:
Navigation Icon Is Different
If what you really want is the back arrow or hamburger icon, that is the navigation icon, not the title icon or logo.
Example:
Or through the action bar:
That enables the Up button, which is different from setting a logo.
Modern Recommendation: Use a Toolbar
In current Android apps, a Toolbar is usually more flexible than relying on the old built-in action bar.
Layout:
Activity setup:
This gives you more control over styling and behavior than the old legacy action bar APIs.
Know Which Icon You Mean
There are at least three different “icons” developers commonly confuse:
- launcher icon shown on the home screen
- logo icon shown inside the toolbar
- navigation icon such as the back arrow
Changing one does not change the others. Many confusing Android UI bugs come from using the right API for the wrong visual element.
Common Pitfalls
One common mistake is trying to change the launcher icon by calling toolbar or action bar methods. That only affects the runtime UI bar, not the app icon in the launcher.
Another mistake is assuming setLogo() will always show the way you expect. Some themes and layouts prioritize the title or home indicator differently.
It is also easy to mix old framework ActionBar code with AppCompat Toolbar code. In a modern app, choose the AppCompat path and stay consistent.
Finally, if supportActionBar is null, the activity probably is not using an action bar theme or has not called setSupportActionBar(toolbar) yet.
Summary
- Change the title with
supportActionBar?.titleor a manifest label. - Change the bar logo with
setLogo()ortoolbar.logo. - Change the back or menu graphic through the navigation icon APIs.
- Prefer a
ToolbarwithsetSupportActionBar()in modern Android apps. - Be clear about whether you mean title, logo, launcher icon, or navigation icon, because they are different UI elements.

