Custom background for ActionBar and SherlockActionBar

Custom background for ActionBar and SherlockActionBar

Feb 1, 2013

When you want to set custom background for Android ActionBar or SherlockActionBar instead of playing with your styles or views, you can use the following simple code snippet.

private Drawable actionBarCustomBackground;

public void onCreate() {

In this case, Drawable object is injected using RoboGuice library and set as a background for the ActionBar. In particular cases, you can use also getActionBar() method. In Drawable object you can store an image of 1 px width and it will be stretched for 100% of width of the ActionBar. I have tested the code snippet presented above for SherlockActionBar and it worked fine.