Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change ActionMode background color in Android

i am creating an android app in which support level api is 7 so i am using sherlock actionbar. I am using action mode in it. Issue is i want to change the background of action mode. So i have tried

    <item name="android:background">@color/something</item>
    <item name="android:backgroundStacked">@color/something</item>
    <item name="android:backgroundSplit">@color/something</item>

these style solution's available but none of them works. enter image description here

like image 696
Love Garg Avatar asked Dec 25 '13 05:12

Love Garg


People also ask

How to change ActionBar color in Android?

xml file: Just go to res/values/styles. xml file. edit the xml file to change the color of action bar.


2 Answers

In my case i resolved with this. First i created a style to define the actionModeBackground:

<style name="MyTheme.ActionMode" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionModeBackground">#FFFFFF</item>
</style>

Then i add the style into my base application theme:

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:actionModeStyle">@style/MyTheme.ActionMode</item>
</style>

Hope it helps!!!

like image 114
Kokusho Avatar answered Nov 06 '22 23:11

Kokusho


if you want change the color of ActionBar just do this:

 ActionBar bar = getActionBar();
 bar.setBackgroundDrawable(new ColorDrawable("COLOR"));

see the following link for more info

and if you using ActionMode This is the style used for any ActionMode. You'll need to create your own style to customize it

<style name="Widget.ActionMode">
<item name="android:background">?android:attr/actionModeBackground</item>
<item name="android:backgroundSplit">?android:attr/actionModeSplitBackground</item>
<item name="android:height">?android:attr/actionBarSize</item>
<item name="android:titleTextStyle">@android:style/TextAppearance.Widget.ActionMode.Title</item>
<item name="android:subtitleTextStyle">@android:style/TextAppearance.Widget.ActionMode.Subtitle</item>
</style>

more info in this site

see this too

Edit

for pre-Honeycomb see this please

maybe this or this helped you

like image 21
Shayan Pourvatan Avatar answered Nov 07 '22 01:11

Shayan Pourvatan