Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove application icon and title from Honeycomb action bar

How can I remove the application icon & title which comes by default in an action bar?

There is a similar question here: Can i hide the App Icon from the Action Bar in Honeycomb?, but it doesn't talk about how to do it?

like image 202
prashant Avatar asked Apr 19 '11 18:04

prashant


People also ask

How do I remove the action bar?

If you want to hide Action Bar from the entire application (from all Activities and fragments), then you can use this method. Just go to res -> values -> styles. xml and change the base application to “Theme. AppCompat.

What is action bar icon?

The ActionBar, now known as the App Bar, is a consistent navigation element that is standard throughout modern Android applications. The ActionBar can consist of: An application icon. An "upward" navigation to logical parent. An application or activity-specific title.


2 Answers

Call setDisplayShowHomeEnabled() and setDisplayShowTitleEnabled() on ActionBar, which you get via a call to getActionBar().

like image 108
CommonsWare Avatar answered Sep 19 '22 12:09

CommonsWare


If you want to do it the XML way, then define a style (XML file) in the /res/values-v11/ folder with the following contents:

<?xml version="1.0" encoding="utf-8"?> <resources>     <style name="MyTheme" parent="android:style/Theme.Holo">         <item name="android:actionBarStyle">@style/MyActionBarStyle</item>     </style>      <style name="MyActionBarStyle" parent="@android:style/Widget.Holo.ActionBar">         <item name="android:displayOptions"></item>     </style> </resources> 

In your AndroidManifest.xml set the theme defined above for your activity:

<activity     ...     android:theme="@style/MyTheme">     ... </activity> 

This will remove the icon and the title and only display the action items. If you just want the title to be displayed, the use:

<item name="android:displayOptions">showTitle</item> 

Or just the application logo:

<item name="android:displayOptions">showHome</item> 

Or both (default)

<item name="android:displayOptions">showHome|showTitle</item> 

Other options are available too, like: showCustom, useLogo, homeAsUp

like image 38
Bert Regelink Avatar answered Sep 20 '22 12:09

Bert Regelink