如何更改自定义创建的工具栏中菜单的颜色?

How do I change the color of menu in a custom created toolbar?

我有一个主页,我在其中创建了一个自定义工具栏,现在我需要向其中添加菜单项。到目前为止,我已经成功了,我的 search 图标处于 app:showAsAction="always" 模式(白色),但是当我在 app:showAsAction="never" 模式下添加任何内容时,菜单指示器(三个点)显示为黑色,但我想要白色。

AndroidManifest.xml

<activity
        android:name=".HomePage"
        android:launchMode="singleTask" />

actvity_homepage.xml

<com.google.android.material.appbar.AppBarLayout
    android:id="@+id/appBarLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintVertical_bias="0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        app:titleTextColor="#ffffff"
        style="@style/ToolbarTheme"
        android:textAlignment="textStart"
        android:background="#2B772E"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

homepage_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item android:id="@+id/logoutmenu"
    android:title= "Log Out"
    android:icon="@drawable/logout"
    app:itemIconTint = "#ffffff"
    app:showAsAction="never"/>
<item
    android:id="@+id/search"
    android:icon="@drawable/search"
    app:showAsAction="always"
    android:title="Hello" />
</menu>

(第一种方式)您的风格:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    ...
    <item name="actionOverflowButtonStyle">@style/MyOverflowButtonStyle</item>
</style>

<style name="MyOverflowButtonStyle" parent="Widget.AppCompat.ActionButton.Overflow">
    <item name="android:tint">#62ff00</item>
</style>

或者你可以用这样的工具栏样式来改变它:

<android.support.v7.widget.Toolbar
  ...
  theme="@style/MyToolbarStyle"
/>

按照您的风格:

<style name="MyToolbarStyle" parent="ThemeOverlay.AppCompat.ActionBar">
  <item name="android:textColorSecondary">#333333</item>
</style>