繁体   English   中英

如何更改工具栏菜单项文本颜色?

[英]How to change toolbar menu item text color?

我已经看到了很多关于同一问题的解决方案。 但没有任何解决方案对我有用。

这是更改工具栏中菜单项文本颜色的最佳解决方案。

在定义新样式时扩展“AppTheme.AppBarOverlay”而不是“Theme.AppCompat.Light.DarkActionBar”。 这不仅会更改菜单项文本颜色,还会保留导航图标的默认颜色。

样式文件

<style name="myCustomMenuTextApearance" parent="AppTheme.AppBarOverlay">
    <item name="actionMenuTextColor">@color/colorAccent</item>

工具栏

<android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"
            android:background="?attr/colorPrimary"
            android:theme="@style/myCustomMenuTextApearance"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

在 menu.xml 文件中使用您的主题,因为您要添加到工具栏中的所有项目都在这里。 我认为,您可以使用项目的属性色调来更改外观颜色。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM