Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fully transparent ActionBarSherlock by using theme

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?

like image 907
Cheok Yan Cheng Avatar asked Apr 17 '12 06:04

Cheok Yan Cheng


1 Answers

<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>
like image 62
Paul Burke Avatar answered Oct 17 '22 18:10

Paul Burke