Show ImageView partly behind transparent ActionBar

You can enable overlay mode of the ActionBar. To do it you have to set (android:)windowActionBarOverlay item in the theme to true.

<style name="MyTheme" parent="Theme.Sherlock">
    ...
    <item name="windowActionBarOverlay">true</item> <!-- for ActionBarSherlock -->
    <item name="android:windowActionBarOverlay">true</item>
</style>

You can also set it at run-time:

requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

This will the ActionBar a semi-transparent floating bar.

Like any requestWindowFeature..., this should be called before adding content.

After the setContentView, you can then set a background from your Drawable with this:

getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg));

Change getActionBar with getSupportActionBar for ActionBarSherlock

actionbar_bg.xml with the root element of shape:

<solid android:color="#64000000" />

Although I find Tomik's solution great, this will be useful for those one-off cases for a few activities rather than an across the board style.


If someone needs the transparent bar but only for certain activities while using a solid one in the rest of them, it might be worth creating two different styles and using the manifest to get control over it:

<style name="MyThemeOverlay" parent="Theme.Sherlock">
    ...
    <item name="windowActionBarOverlay">true</item> <!-- for ActionBarSherlock -->
    <item name="android:windowActionBarOverlay">true</item>
    <!-- any stuff common here, colours, etc -->

    <!-- define the style for native ActionBar for Android 4 and higher -->
    <item name="android:actionBarStyle">@style/myActionbarTransparent</item>
    <!-- define the style for ActionBarSherlock -->
    <item name="actionBarStyle">@style/myActionbarTransparent</item>
</style>

<style name="MyThemeNoOverlay" parent="MyTheme">
    <item name="windowActionBarOverlay">false</item> <!-- for ActionBarSherlock -->
    <item name="android:windowActionBarOverlay">false</item>
    <!-- any stuff specific for no overlay activity action bars -->

    <!-- define the style for native ActionBar for Android 4 and higher -->
    <item name="android:actionBarStyle">@style/myActionbar</item>
    <!-- define the style for ActionBarSherlock -->
    <item name="actionBarStyle">@style/myActionbar</item>
</style>

<style name="myActionbar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">@color/white</item>
</style>
<style name="myActionbarTransparent" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">@color/transparent</item>
</style>

and then in your AndroidManifest.xml you can either use one of them as default and the other one for some specific activities by doing something like:

<application
    ...
    android:theme="@style/MyThemeOverlay">
    ...
    <activity
      android:name=".Activity1"       
      />
    <activity
      android:name=".Activity2"    
      android:theme="@style/MyThemeNoOverlay"   
      />
    <activity
      android:name=".Activity3"       
      />
    <activity
      android:name=".Activity4"       
      android:theme="@style/MyThemeNoOverlay"
      />

...