Artem
Artem

Reputation: 4639

How to change color in ActionBar when I start ActionMode

When I start ActionMode (I make this when I set items in ListView) my ToolBar change background color from dark to white and I got this:

enter image description here

How you can see - it's looked bad.

How I can change ToolBar background color when ActionMode is activated?

Upvotes: 0

Views: 76

Answers (1)

Kishan Soni
Kishan Soni

Reputation: 816

Change the ActionMode background with use of actionModeStyle attribute

<style name="AppTheme.Base" parent="Theme.AppCompat.Light">
....
....
<item name="actionModeStyle">@style/LStyled.ActionMode</item>
</style>

<style name="LStyled.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
<item name="background">@color/color_action_mode_bg</item>
</style>

You need to define a color named color_action_mode_bg:

<color name="color_action_mode_bg">#009688</color>

There are other things you can change as well. e.g:

<item name="titleTextStyle">...</item>
<item name="subtitleTextStyle">...</item>
<item name="height">...</item>

To change text color of text Citroen add the following to AppTheme.Base:

<item name="actionMenuTextColor">@color/color_action_mode_text</item>

Updated Code

<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>

Upvotes: 1

Related Questions