Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionBarSherlock - actionbar custom background with divider

I'm implementing ActionBarsherlock and I want to change the actionbar background.

I override the properties but the blue divider dissapear. How can I use custom background with the blue divider?

<style name="Theme.MyTheme" parent="Theme.Sherlock.ForceOverflow">     <item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>     <item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item> </style>  <style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.ActionBar">     <item name="android:background">#ff3e3f3d</item>     <item name="background">#ff3e3f3d</item> </style> 

like image 766
ikarius Avatar asked Apr 28 '12 13:04

ikarius


2 Answers

For anyone who (like me) doesn't enjoy playing around with 9-patch images, you can get the divider at the bottom of the action bar using an xml drawable:

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">     <!-- Bottom Line -->     <item>         <shape android:shape="rectangle">             <solid android:color="@color/action_bar_line_color" />         </shape>     </item>      <!-- Color of your action bar -->     <item android:bottom="2dip">         <shape android:shape="rectangle">             <solid android:color="@color/action_bar_color" />         </shape>     </item> </layer-list> 

Save this as drawable/action_bar_background.xml, Then apply it in your theme:

<style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.ActionBar">     <item name="android:background">@drawable/action_bar_background</item>     <item name="background">@drawable/action_bar_background</item> </style> 
like image 77
DanielGrech Avatar answered Oct 05 '22 22:10

DanielGrech


http://jgilfelt.github.io/android-actionbarstylegenerator/

This project can be used to generate ActionBar style you need.

like image 45
kzotin Avatar answered Oct 05 '22 22:10

kzotin