Android – Set gradient for Android ActionBar

actionbarsherlockandroidandroid-actionbarxml-drawable

I use an ActionBarSherlock library in my app. I also needed to customize the ActionBar, so I added a custom theme with a background parameter set, like this:

<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">

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

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

</style>

action_bar_bg drawable is simply a bitmap of tiled squares:

<?xml version="1.0" encoding="utf-8"?>

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:dither="true"
    android:src="@drawable/bg_img_actionbar"
    android:tileMode="repeat" />

What I want to do next is to set a linear gradient for a whole ActionBar, so it will cover this background. And I have no idea if it's possible and how to do that.
Any help would be appreciated.

Best Answer

There is a type of resource for this, Shape Drawable: http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape