6

I am currently working on making my application compatible with pre 3.0 devices with the aid of actionbarsherlock. My application has a custom theme which overide Holo.light changing the blue to orange.

I am wanting to change the blue line which appears under the actionbar to orange. With the official actionbar I managed this by overriding

    <item name="android:background">@drawable/ad_tab_unselected_holo</item>

Unfortunately this does not seem to be working in actionbarsherlock 4.

bencallis
  • 3,478
  • 4
  • 32
  • 58

1 Answers1

5

You need to do two things:

The ABS 4 now mimics the standard Action bar with its attributes so you need to add -

<item name="background">@drawable/ad_tab_unselected_holo</item>

Notice the absence of android:

So your overall code would be:

<item name="android:background">@drawable/ad_tab_unselected_holo</item>
<item name="background">@drawable/ad_tab_unselected_holo</item>

To quote:

Due to limitations in Android's theming system any theme customizations must be declared in two attributes. The normal android-prefixed attributes apply the theme to the native action bar and the unprefixed attributes are for the custom implementation. Since both theming APIs are exactly the same you need only reference your customizations twice rather than having to implement them twice.

I would also extend a varient of Theme.Sherlock rather than holo, as I believe holo is not available on older devices that are pre 3.0.

Graham Smith
  • 25,627
  • 10
  • 46
  • 69
  • 1
    Yes, you need to extend Theme.Sherlock or another theme provided by ABS 4. – Jon Willis Apr 06 '12 at 14:01
  • Also, in my findings, I need to have android:background AND background for styling to work consistently across all versions of Android. Maybe I'm flat out wrong or this changed, though. – Jon Willis Apr 06 '12 at 14:02
  • Notice I said *add* - not replace therefore BOTH variants would be present. – Graham Smith Apr 06 '12 at 14:03
  • I was caught up by the "Notice the absence of android:" This was before you had the `android:background` line above the `background` there. – Jon Willis Apr 06 '12 at 14:08
  • After what you said I thought I would save some confusion and my point clear :) – Graham Smith Apr 06 '12 at 14:09
  • Thanks don't know how I missed that. I have styled other aspects this way but simply overlooked this! I thought the point of Theme.holo was to bring holo back to devices prior to 3.0? It is successfully working on a device running 2.3 :) – bencallis Apr 06 '12 at 14:40