Reputation: 5673
I want to change the action overflow button icon in my Toolbar
(or ActionBar
, not matter).
So I go this way:
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:actionOverflowButtonStyle">@style/AppTheme.OverflowButtonStyle</item>
</style>
<style name="AppTheme.OverflowButtonStyle" parent="Widget.AppCompat.Light.ActionButton.Overflow">
<item name="android:src">@drawable/ic_custom</item>
</style>
or this way:
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="toolbarStyle">@style/AppTheme.ToolbarStyle</item>
</style>
<style name="AppTheme.ToolbarStyle" parent="Base.Widget.AppCompat.Toolbar">
<item name="actionOverflowButtonStyle">@style/AppTheme.OverflowButtonStyle</item>
</style>
<style name="AppTheme.OverflowButtonStyle" parent="Widget.AppCompat.Light.ActionButton.Overflow">
<item name="android:src">@drawable/ic_custom</item>
</style>
But both ways don't work. What's wrong there?
And the second question is can I change one resourse from library to another resource from library (I just want to change black action overflow button to white, which presents in the library too).
Upvotes: 8
Views: 7596
Reputation: 364005
You can define the overflow icon in the app theme using the actionOverflowButtonStyle
attribute.
With a Material Components Theme:
<style name="AppTheme.Base" parent="Theme.MaterialComponents.DayNight">
<item name="actionOverflowButtonStyle">@style/OverFlow</item>
</style>
<style name="OverFlow" parent="Widget.AppCompat.ActionButton.Overflow">
<item name="srcCompat">@drawable/my_overflow_menu</item>
</style>
With an AppCompat Theme:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="actionOverflowButtonStyle">@style/OverFlow</item>
</style>
<style name="OverFlow" parent="Widget.AppCompat.ActionButton.Overflow">
<item name="android:src">@drawable/ic_myoverflow</item>
</style>
With appcompat you have to use the attributes without the android namaspace.
Upvotes: 25