My main theme is based on Theme.AppCompat.Light
as follows:
<style name="core" parent="Theme.AppCompat.Light" >
<!-- Material, Yo!-->
<item name="colorPrimary">@color/theme_main_color</item>
<item name="colorPrimaryDark">@color/deep_purple</item>
<item name="colorAccent">@color/theme_accent_color</item>
<item name="android:navigationBarColor" tools:ignore="NewApi">?attr/colorPrimary</item>
<!-- Toolbar -->
<item name="theme">@style/my_toolbar_theme</item>
<item name="drawerArrowStyle">@style/my_drawer_arrow</item>
<!-- Actionbar -->
<item name="android:actionBarDivider">@null</item>
<item name="android:actionBarTabStyle">@null</item>
<item name="android:actionBarTabBarStyle">@null</item>
<!-- Contextual Actionbar -->
<item name="windowActionModeOverlay">true</item>
<item name="actionModeBackground">?attr/colorAccent</item>
<item name="actionModeStyle">@style/my_actionmode_style</item>
</style>
<style name="my_drawer_arrow" parent="Widget.AppCompat.DrawerArrowToggle" >
<item name="spinBars">true</item>
<item name="color">@color/theme_accent_color</item>
</style>
<style name="my_toolbar_style">
<item name="android:id">@id/toolbar</item>
<item name="android:minHeight">?attr/actionBarSize</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">match_parent</item>
<item name="android:background">?attr/colorPrimary</item>
<item name="android:elevation" tools:ignore="NewApi">5dp</item>
</style>
<style name="my_actionmode_style" parent="Widget.AppCompat.Light.ActionMode.Inverse" >
<item name="titleTextStyle">@style/my_actionmode_title_style</item>
<item name="subtitleTextStyle">@style/my_actionmode_subtitle_style</item>
</style>
<style name="my_toolbar_style.gradient">
<item name="android:background">@drawable/ab_gradient_bg</item>
</style>
<style name="my_toolbar_theme" parent="ThemeOverlay.AppCompat.Dark.ActionBar" >
<!-- Customize the toolbar here -->
</style>
<style name="my_actionmode_title_style" parent="TextAppearance.AppCompat.Widget.ActionMode.Title">
<item name="android:textColor">@color/std_white</item>
</style>
<style name="my_actionmode_subtitle_style" parent="TextAppearance.AppCompat.Widget.ActionMode.Subtitle">
<item name="android:textColor">@android:color/white</item>
</style>
In actionmode I'd like to see white title/subtitles with a white back arrow. I've been able to set the title and subtitle text colors to white, but the back arrow remains black. This issue only occurs in places where I'm using the SupportActionbar and not the toolbar (the back arrow in toolbar is white).
This is my toolbar in ActionMode.
This is the actionbar in ActionMode. Same phone, same app, same themes, just a different activity.
I can't find anything in the themes that would determine this color. According to the source, the icon is @drawable/abc_ic_ab_back_mtrl_am_alpha
, which is white, so something must be tinting it. Where does this black-ish color come from?
To customize this using AppCompat:
In your app level theme:
<style name="MyTheme" parent="Theme.AppCompat.Light">
<item name="actionModeCloseButtonStyle">@style/myclosebutton</item>
</style>
In the CloseButtonStyle:
<style name="myclosebutton" parent="Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:tint">#ff0</item> <!-- whatever color -->
</style>
I had the same problem and I have solved it by explicitly declaring the icon I want to use in the style:
<item name="android:actionModeCloseDrawable">@drawable/ab_back</item>
Where @drawable/ab_back is provided by me.
This is not ideal, as I would like to correctly set the style and let it work inheriting the right colours from the parent theme, without the need of declaring so specific details. But, I feel everything around the ActionBar, SupportActionBar, SherlockActionBar, ActionBarActivity, FragmentActivityWithASherlockSupportActionToolbar is SO broken and bad engineered that I'm happy to solve it with a workaround.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With