With the AppCompat Toolbar, I want to be able to change the color of the overflow menu icon on ActionMode change.
For example, the overflow icon will be white in normal Toolbar mode. And will turn black on ActionMode. So far, I have managed to change the background of the action mode as well as the title text. But I have yet to find a way to change the overflow menu icon color.
I know that there's an answer available: Change ActionMode Overflow icon
I tried the first solution and I wasn't able to find the overflow icon.
The second solution, even with a 50L delay causes the overflow menu icon to flash the ActionMode's intended color for a brief split second that is very jarring.
Add the below line into your theme attribute:
<item name="android:textColorSecondary">@android:color/white</item>
This can be achieved by setting the android:textColorSecondary
theme attribute.
For example, suppose you have the following toolbar, which uses the theme MyToolbarStyle
:
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
theme="@style/MyToolbarStyle"
/>
Next, define the style MyToolbarStyle
, inheriting from ThemeOverlay.AppCompat.ActionBar
. Finally, modify the color of the overflow icon by adding an item for android:textColorSecondary
:
<style name="MyToolbarStyle" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorSecondary">#333333</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:actionOverflowButtonStyle">@style/ActionButton.Overflow.Icon</item>
</style>
<style name="ActionButton.Overflow.Icon" parent="android:style/Widget.Holo.Light.ActionButton.Overflow">
<item name="android:src">@mipmap/yourwanticon</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionOverflowButtonStyle">@style/ActionButtonOverflow</item>
<!-- Support library compatibility -->
<item name="actionOverflowButtonStyle">@style/ActionButtonOverflow</item>
</style>
<style name="ActionButtonOverflow" parent="@style/Widget.AppCompat.ActionButton.Overflow">
<item name="android:tint">@color/brand_white</item>
</style>
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