Fully transparent ActionBarSherlock by using theme

Cheok Yan Cheng picture Cheok Yan Cheng · Apr 17, 2012 · Viewed 7.4k times · Source

I am using ActionBarSherlock 4.0.2.

I need a fully transparent action bar (without the neon color bottom divider). Hence, I have the following style:

<style name="AppTheme" parent="@style/Theme.Sherlock">
    <item name="windowActionBarOverlay">true</item>
    <item name="icon">@drawable/ic_home</item>
    <item name="titleTextStyle">@style/ActionBarCompatTitle</item>
    <item name="android:windowFullscreen">true</item>
</style>

By using above code, I will still have the following effect.

SherlockFragmentActivity wit divider and with half-transparent background

In order to disable the background, I put the following code in SherlockFragmentActivity#onCreate. Then the problem gone.

getSupportActionBar().setBackgroundDrawable(null);

SherlockFragmentActivity without divider and with transparent background

However, I would like to see the solution being implemented in styles.xml instead of Java code, as I have many other devices with different screen configuration. I modified the styles.xml to the following, without using the previously mentioned fix in the Java code.

<style name="AppTheme" parent="@style/Theme.Sherlock">
    <item name="windowActionBarOverlay">true</item>
    <item name="icon">@drawable/ic_home</item>
    <item name="titleTextStyle">@style/ActionBarCompatTitle</item>
    <item name="android:windowFullscreen">true</item>

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

However, the neon divider still visible. It seems that my fix using android:background and background does not work. Am I missing something?

Answer

Paul Burke picture Paul Burke · Sep 26, 2012
<style name="AppTheme" parent="@style/Theme.Sherlock">
    <item name="actionBarStyle">@style/AppTheme.ActionBar</item>
    <item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
</style>

<style name="AppTheme.ActionBar" parent="@style/Widget.Sherlock.ActionBar">
    <item name="background">@android:color/transparent</item>
    <item name="android:background">@android:color/transparent</item>
</style>