4

i'm trying to create the a flat action bar without shadow

attached image:

enter image description here

my style xml

<resources>

<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:windowContentOverlay">@null</item>
            <item name="android:windowActionBarOverlay">true</item>

    <item name="android:background">@drawable/white_bg</item>
    <item name="android:displayOptions"></item>
</style>

I'm supporting android 4.x

Any ideas ? I tried changing the style to Solid/Inverse didn't work..

white_bg attached (It's hard to see since it's white)

enter image description here

SPatrickApps
  • 538
  • 8
  • 21
ibm123
  • 1,214
  • 2
  • 15
  • 39

2 Answers2

8

it should look like this

<resources>

<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">

            <item name="android:windowActionBarOverlay">true</item>

    <item name="android:background">@drawable/white_bg</item>
    <item name="android:displayOptions"></item>
</style>
SPatrickApps
  • 538
  • 8
  • 21
  • I actually wanted the opposite; mainly, android:windowContentOverlay = @drawable/my_shadow and android:windowActionBarOverlay = true. This solution works for that scenario if @null is replaced with the name of the desired shadow drawable. Thanks! – Chris Sprague Jun 02 '14 at 19:27
  • this works, but, it removes the actionbar title, what can i do to get it back? – Edgar Jun 13 '14 at 14:31
  • @Edgar try changing the title text color [link on how to do it](http://stackoverflow.com/questions/5861661/actionbar-text-color) – SPatrickApps Jul 03 '14 at 15:58
1

The null windowContentOverlay attribute should be set on your Activity theme (CustomActionBarTheme), not on the ActionBar theme.

Kevin Coppock
  • 133,643
  • 45
  • 263
  • 274