Change color of the overflow button on ActionBar

2020-01-24 07:53发布

Is it possible to change the color of the overflow button(3 vertical dots) on the action bar? If so, how do we do that? I didn't find any style for overflow button.

Thanks

13条回答
SAY GOODBYE
2楼-- · 2020-01-24 08:09

For Overflow icon color change, you can just add

toolbar.setOverflowicon(getDrawable)
查看更多
够拽才男人
3楼-- · 2020-01-24 08:11

Some of these answers are serious overkill and some give limited results. The answer is much simpler. You can set it to whatever color you want, any time. Here:

toolbar.getOverflowIcon().setColorFilter(colorInt, PorterDuff.Mode.SRC_ATOP);
查看更多
干净又极端
4楼-- · 2020-01-24 08:14
<style name="MyCustomTheme" parent="@style/Theme.AppCompat.Light">
  <item name="actionOverflowButtonStyle">@style/OverflowMenuButtonStyle</item>
</style>
<style name="OverflowMenuButtonStyle" parent="Widget.AppCompat.ActionButton.Overflow">
  <item name="android:src">@drawable/quantum_ic_more_vert_white_24</item>
</style>

Note that this is different from XGouchet's answer by removing android namespace. XGouchet's answer only works for Lollipop and higher devices while mine works for all API 7+ devices.

ref: Custom AppCompat Theme not changing Overflow icon on older devices

查看更多
Bombasti
5楼-- · 2020-01-24 08:15

If you are using AppCompat , you could derive a new custom style with the attribute android:textColorSecondaryset to the required color, and use it as the theme for your toolbar. Android: Changing the Toolbar’s text color and overflow icon color

查看更多
混吃等死
6楼-- · 2020-01-24 08:23

Putting images is not a great idea, because if you can change it by changing colors only then no need to use an extra image. The menu dots picks color from textColorPrimary, so rather than writing multiple lines this single line <item name="android:textColorPrimary">@android:color/white</item> will fix your problem. Only a small problem is that this color will be apply to the textcolor of your overflow menu also, and lots of other places of-course :)

查看更多
我命由我不由天
7楼-- · 2020-01-24 08:26

XGouchet's answer is great, but just wanted to add that if you inherit from an existing style you'll get the standard padding, selected state, etc.

<style name="MyCustomTheme.OverFlow" parent="Widget.Sherlock.ActionButton.Overflow">
    <item name="android:src">@drawable/title_moreicon</item>
</style>
查看更多
登录 后发表回答