Hide action bar title

12,386 views
Skip to first unread message

Lukasz Piliszczuk

unread,
Apr 18, 2012, 6:29:48 PM4/18/12
to actionba...@googlegroups.com
Hello,

I'm trying to hide the title on the action bar and show only the logo.
There is two ways to do that.

The first one works well but I have to repeat it on all my activities : 
getSupportActionBar().setDisplayShowTitleEnabled(false);

But if I try to do the same by xml then I can't make it work :
<style name="foobar" parent="Theme.Sherlock.Light.ForceOverflow">
        <item name="android:displayOptions">showHome|useLogo</item>
</style>

Am I doing something wrong ?
Thank you.

Jake Wharton

unread,
Apr 18, 2012, 6:44:41 PM4/18/12
to actionba...@googlegroups.com
You need to include an <item> tag with a non-android prefixed line as well.


<style name="foobar" parent="Theme.Sherlock.Light.ForceOverflow">
        <item name="android:displayOptions">showHome|useLogo</item>
        <item name="displayOptions">showHome|useLogo</item>
</style>

---
Jake Wharton
http://about.me/jakewharton

Lukasz Piliszczuk

unread,
Apr 19, 2012, 6:42:46 AM4/19/12
to actionba...@googlegroups.com
Still don't work, the logo and the title are both visible on the action bar.
With this style :

<style name="foobar" parent="Theme.Sherlock.Light.ForceOverflow">
        <item name="android:displayOptions">showHome|useLogo</item>
        <item name="displayOptions">showHome|useLogo</item>
</style>

And the manifest :

<application android:name="com.siu.impactsante.Application"
                 android:icon="@drawable/icon"
                 android:logo="@drawable/logo"
                 android:label="@string/app_name"
                 android:theme="@style/foobar">
</application>

Jake Wharton

unread,
Apr 19, 2012, 1:21:55 PM4/19/12
to actionba...@googlegroups.com
Oh that was my bad. Those attributes need to go in the action bar style, not the theme itself.

<style name="FooBar" parent="Theme.Sherlock.Light.ForceOverflow">
    <item name="android:actionBarStyle">@style/FooBar.ActionBar</item>
    <item name="actionBarStyle">@style/FooBar.ActionBar</item>
</style>

<style name="FooBar.ActionBar" parent="Widget.Sherlock.ActionBar.Light">
    <!-- display options stuff here -->
</style>

---
Jake Wharton
http://about.me/jakewharton


Lukasz Piliszczuk

unread,
Apr 19, 2012, 3:17:44 PM4/19/12
to actionba...@googlegroups.com
This is perfect !
I just changed Widget.Sherlock.ActionBar.Light by Widget.Sherlock.ActionBar because the first one dosen't exist.

<style name="Theme.App" parent="Theme.Sherlock.Light">
        <item name="android:actionBarStyle">@style/Theme.App.ActionBar</item>
        <item name="actionBarStyle">@style/Theme.App.ActionBar</item>
    </style>

    <style name="Theme.App.ActionBar" parent="Widget.Sherlock.ActionBar">
        <item name="android:displayOptions">showHome|useLogo</item>
        <item name="displayOptions">showHome|useLogo</item>
</style>

Thank you very much !

On Thursday, April 19, 2012 7:21:55 PM UTC+2, Jake Wharton wrote:
Oh that was my bad. Those attributes need to go in the action bar style, not the theme itself.

<style name="FooBar" parent="Theme.Sherlock.Light.ForceOverflow">
    <item name="android:actionBarStyle">@style/FooBar.ActionBar</item>
    <item name="actionBarStyle">@style/FooBar.ActionBar</item>
</style>

<style name="FooBar.ActionBar" parent="Widget.Sherlock.ActionBar.Light">
    <!-- display options stuff here -->
</style>

---
Jake Wharton
http://about.me/jakewharton


Jake Wharton

unread,
Apr 19, 2012, 3:18:52 PM4/19/12
to actionba...@googlegroups.com
It's Widget.Sherlock.Light.ActionBar. I think all these styles is turning my brain into mush...

Glad you got it working.

qde

unread,
Jul 31, 2012, 3:02:47 PM7/31/12
to actionba...@googlegroups.com
Hi,

i have a problem with the posted code below. i'm getting about 100 errors like this in the console:
[2012-07-31 20:50:30 - myactivity]  C:\mypath\JakeWharton-ActionBarSherlock-88fc341\libar\res\values-v14\abs__themes.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar'.
[2012-07-31 20:50:30 - myactivity] C:\mypath\JakeWharton-ActionBarSherlock-88fc341\library\res\values-v14\abs__themes.xml:14: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.

snippet from the manifest.xml
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/Theme.Sherlock" >...../<pplication>

my xml in res/values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.App" parent="Theme.Sherlock">

        <item name="android:actionBarStyle">@style/Theme.App.ActionBar</item>
        <item name="actionBarStyle">@style/Theme.App.ActionBar</item>
    </style>
    <style name="Theme.App.ActionBar" parent="Widget.Sherlock.ActionBar">
        <item name="android:displayOptions">showHome|useLogo</item>
        <item name="displayOptions">showHome|useLogo</item>
    </style>
</resources>

i'm using ABS 4.1. Is the reference to "Widget.Sherlock.ActionBar" correct?
thanks!


Am Donnerstag, 19. April 2012 21:18:52 UTC+2 schrieb Jake Wharton:
It's Widget.Sherlock.Light.ActionBar. I think all these styles is turning my brain into mush...

Glad you got it working.

---
Jake Wharton
http://about.me/jakewharton


Jake Wharton

unread,
Jul 31, 2012, 3:17:05 PM7/31/12
to actionba...@googlegroups.com
You need to compile with Android 4.0+

Felix Liese

unread,
Jul 31, 2012, 3:22:11 PM7/31/12
to actionba...@googlegroups.com
Hm. But I want to be 2.3.3 compatible. That is the only reason for using ABS. Whitout the styles.xml the app runs on 2.3.3 very well.

2012/7/31 Jake Wharton <jakew...@gmail.com>

Jake Wharton

unread,
Jul 31, 2012, 3:27:39 PM7/31/12
to actionba...@googlegroups.com
Compilation SDK and minimum SDK are orthogonal. You should make every effort to compile with the latest SDK available.

Felix Liese

unread,
Jul 31, 2012, 3:42:34 PM7/31/12
to actionba...@googlegroups.com
oh okay. thank you for this advice

the compile error disappeared but i still got the title and an icon on the top of the app.
sorry for engaging your time! :(

2012/7/31 Jake Wharton <jakew...@gmail.com>

Felix Liese

unread,
Jul 31, 2012, 7:35:18 PM7/31/12
to actionba...@googlegroups.com
ahh ive been sleeping no very much. i just forgot to reference the new themename in the manifest. :)
now it works. yeah. thank you very much for your hint with the sdk version!

2012/7/31 Felix Liese <fli...@gmail.com>

Fabio Cingolani

unread,
Apr 17, 2013, 2:14:52 PM4/17/13
to actionba...@googlegroups.com
Hi! this is my first try with abs so i may have confused something

First, i want to thank Jake for the work. It's brilliant...

then... i'm trying to hide the app title from the action bar in this way, but nothing changes

this is what i've done

<style name="Theme.MyApp" parent="Theme.Sherlock.Light">
    
    <item name="android:actionBarStyle">@style/Theme.MyApp.ActionBarStyle</item>
    <item name="actionBarStyle">@style/Theme.MyApp.ActionBarStyle</item>

</style>


<style name="Theme.MyApp.ActionBarStyle" parent="Widget.Sherlock.Light.ActionBar">
<item name="android:titleTextStyle">@style/Theme.MyApp.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">@style/Theme.MyApp.ActionBar.TitleTextStyle</item>
<item name="background">#64a85b</item>
<item name="android:background">#64a85b</item>
<item name="android:displayOptions">showHome|useLogo</item>
<item name="displayOptions">showHome|useLogo</item>
</style>


The other options work as well...the displayOption is the only thing that's still doesn't work 

Thanks!

Fabio Cingolani

unread,
Apr 17, 2013, 2:18:25 PM4/17/13
to actionba...@googlegroups.com
I've forgot to mention that this

getSupportActionBar().setDisplayShowTitleEnabled(false);

doesn't work too

Edison Santos

unread,
Mar 23, 2014, 3:40:00 PM3/23/14
to actionba...@googlegroups.com
Hi Lukasz!

I was going through the exact same thing as you. I did those configurations on my styles and the actionbar text was hidden as I wanted to. Problem is, my actionbar options I had previously also got hidden. Any ideas?

Many thanks.

Edison Santos

unread,
Mar 23, 2014, 4:49:54 PM3/23/14
to actionba...@googlegroups.com
Sorry for bothering you!

I changed my project in order to use the ActionBarSherlock, but I wasn't extending SherlockFragment, I was still using Fragment. That solved the issue.

Thanks anyway ;)

swetha eemani

unread,
Sep 23, 2014, 5:16:39 AM9/23/14
to actionba...@googlegroups.com
Am getting an error No resource Found-- Theme.Sherlock.Light.ForceOverflow,Widget.Sherlock.ActionBar
Reply all
Reply to author
Forward
0 new messages