2

我在工具栏中使用工具栏进行材质设计。一切工作正常,但除了当涉及到更改菜单项文字颜色,我完全坚持解决方案。我也张贴应该采取的文本截图和我在我的应用程序中使用的代码供您参考。我尝试了几种替代方法,如分配如下如何更改棒棒糖和棒棒糖版本的工具栏菜单项文本颜色

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

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

但是,上述解决方案的已知适用于我。

要求截图:

enter image description here

需要跳过菜单项,从黑色变为白色。

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> 

我真的不知道w ^在这里我犯了错误。请帮帮我。在此先感谢

回答

17

更改此

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

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

并应用主题到工具栏:

android:theme="@style/ToolBarTheme" 

你的风格你的小部件,并为您的活动提供的主题。

+0

谢谢。它效果很好。 – Chandru

+0

我接受你的回答 – Chandru

+0

很高兴帮助。 – Raghunandan