How to Customize the Action Mode's Color and Text

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

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>

How can I change text/icon color in Action Mode?

Use following snippet to change ActionMode background color + Title Color + Back Button Color

styles.xml

<style name="ActionModeStyle" parent="@style/Widget.AppCompat.ActionMode">
<item name="background">@color/colorPrimary</item>
<item name="titleTextStyle">@style/ActionModeTitleTextStyle</item>
</style>

<style name="ActionModeTitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionMode.Title">
<item name="android:textColor">@android:color/white</item>
</style>

themes.xml

<item name="actionModeStyle">@style/ActionModeStyle</item>
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>

Please Note: actionBarTheme will be responsible for setting back
button color to white.

How to change ActionMode background color in Android

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

How to set font color for action menu items in Material night theme?

Managed to solve it after losing a few hours looking at the wrong place...

In the generated app_bar_main.xml where the action bar is added to the layout, there's

<com.google.android.material.appbar.AppBarLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:theme="@style/Theme.AppName.AppBarOverlay">

In themes.xml there's an empty style for it

<style name="Theme.Test3.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

To change the text of action manu items, add the textColor parameter to it:

<style name="Theme.AppName.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColor">@color/white</item>
</style>

This style can be added to both values/themes.xml and values-night/themes.xml to have different colors for the dark and light themes.



Related Topics



Leave a reply



Submit