如何更改Lollipop之前和Lollipop版本的工具栏菜单项文本颜色 [英] How to change toolbar menu item text color for pre Lollipop and Lollipop versions

查看:72
本文介绍了如何更改Lollipop之前和Lollipop版本的工具栏菜单项文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用工具栏进行应用程序中的材料设计.一切工作正常,但是除非要更改菜单项文本颜色,否则我完全无法解决该问题.我还将发布应该在应用程序中使用的文本和代码的屏幕截图,以供您参考.我尝试了几种替代方法,例如分配如下

I am using Toolbar for the purpose of material design in my application. Everything working fine but except when it comes to change the menu item text color I am completely stuck up with the solution. I am also posting screenshot of the text that should be taken and code I am using in my application for your reference. I tried several alternate methods like assigning as follows

<item name="android:actionMenuTextColor">@color/white</item>

<item name="android:textColor">#000</item>

但是上述解决方案中的已知方法对我有用.

But known of the above solutions works for me.

需求屏幕截图:

需要将跳过"菜单项从黑色更改为白色.

Need to change SKIP menu item from black to white color.

styles.xml

<style name="ToolBarTheme" parent="@style/Theme.AppCompat.Light">
        <item name="colorPrimary">@color/blue</item>
        <item name="colorPrimaryDark">@color/blue</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
        <item name="android:actionMenuTextColor">@color/white</item>
        <item name="android:textColor">#000</item>

    </style>

toolbar.xml

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|enterAlways"
    android:fitsSystemWindows="true"
    android:background="?attr/colorPrimary"/>

清单

<activity
            android:name=".activity.HomeActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboard|screenLayout|orientation"
            android:theme="@style/ToolBarTheme"></activity>

我真的不知道我在哪里犯错.请帮我.预先感谢

I really dont know where I am committing mistake. Please help me. Thanks in advance

推荐答案

更改此内容

<item name="android:actionMenuTextColor">@color/white</item>

<item name="actionMenuTextColor">@color/white</item>

并将主题应用于工具栏:

And apply the theme to the toolbar:

android:theme="@style/ToolBarTheme"

您为小部件设置样式并为您的活动提供主题.

You style your widgets and provide themes for your activity.

这篇关于如何更改Lollipop之前和Lollipop版本的工具栏菜单项文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆