Search code examples
androidcontextual-action-bar

Change the color of the line into the Contextual Action Bar


I would like to change the color of the line that appears onto the contextual action bar; to be more clear I will put an image:

enter image description here

You see the Light blue line just above the white area? How could I change its color? Thanks


Solution

  • You should first create your own 9-patch image with the colours which you want to use. For example an image like this :

    enter image description here

    And after that in your application's theme you should add this (for Holo Theme) :

    <style name="Theme.MyAppTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionModeBackground">@drawable/my_actionmode_background</item>
    </style>
    

    For ActionBarSherlock or AppCompat you should use :

    <!-- AppCompat -->
    <style name="Theme.MyAppTheme" parent="@style/Theme.AppCompat.Light">
        <item name="actionModeBackground">@drawable/my_actionmode_background</item>
    </style>
    
    <!-- ActionBarSherlock -->
    <style name="Theme.MyAppTheme" parent="@style/Theme.Sherlock.Light">
        <item name="actionModeBackground">@drawable/my_actionmode_background</item>
    </style>