Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I customize the Action Mode's color and text?

The default action mode (3.0 and up) comes with a green theme and a 'Done' button on the left side. How can I customize these?

Thanks

like image 384
Zsombor Erdődy-Nagy Avatar asked Jul 02 '11 09:07

Zsombor Erdődy-Nagy


3 Answers

This is the style used for any ActionMode, I pulled it from the SDK. You'll need to create your own style to customize it. It's really easy to do. If you've never done anything like this before, you should read through this post on customizing the ActionBar. It explains everything you'll need to know.

    <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>
like image 161
adneal Avatar answered Nov 12 '22 13:11

adneal


Solution for my application

<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionModeBackground">@color/bg_action_bar</item>
</style>
like image 26
PleaseTwo Avatar answered Nov 12 '22 12:11

PleaseTwo


Worked on my project

 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="actionModeStyle">@style/CustomActionModeStyle</item>
 </style>

Custom ActionMode style

<style name="CustomActionModeStyle" parent="Base.Widget.AppCompat.ActionMode">
        <item name="background">@color/color_primary</item>
        <item name="titleTextStyle">@style/CustomeActionModeTextStyle</item>
</style>

Custom Title ActionMode

<style name="CustomeActionModeTextStyle" parent="TextAppearance.AppCompat.Widget.ActionMode.Title">
    <item name="android:textSize">16sp</item>
    <item name="android:textColor">@color/color_primaryText</item>
</style>
like image 15
Jacky Pham Avatar answered Nov 12 '22 12:11

Jacky Pham