如何使用Android 10中的XML样式改变最左边"Home"图标的颜色

How to change the color of "Home" icon at the leftmost by using XML style in Android 10

ActionBar有两个图标,一个是最右边的"Overflow"图标,一个是最左边的"Home"图标(三横线图标)。

ActionBar "Overflow"(最右边)图标的颜色可以通过以下样式更改:

<style name="ActionBarOverflowStyle" parent="@style/Widget.AppCompat.ActionButton.Overflow" >
    <item name="android:tint">@color/red</item>
</style>

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

但是如何使用XML样式改变最左边"Home"图标的颜色呢?

另外,当导航到下一个片段时,"Back" 图标将出现在 ActionBar 中,如何使用 [= 更改最左侧 "Back" 图标的颜色51=]风格?

布局如下xml:

<com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.PopupOverlay">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:popupTheme="@style/AppTheme.AppBarOverlay" />

</com.google.android.material.appbar.AppBarLayout>

样式如下xml:

<style name="MyThemeOverlay_Toolbar" parent="@style/ThemeOverlay.MaterialComponents.ActionBar">
    <item name="android:tint">@color/red</item>
    <item name="android:iconTint">@color/red</item>
    <item name="android:colorControlNormal">@color/red</item>
</style>

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionOverflowButtonStyle">@style/ActionBarOverflowStyle</item>
    <item name="android:actionBarStyle">@style/MyThemeOverlay_Toolbar</item>
</style>

"Menu"图标的颜色无法通过此样式配置更改。

谢谢。

在@GabrieleMariotti 的帮助下,这里是设置 "Home" 和 "Overflow" 图标的答案。

首先,从 AppBarLayout 中删除 android:theme 属性,从布局中删除 Toolbar xml:

<com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"/>

</com.google.android.material.appbar.AppBarLayout>

其次,在样式中设置以下项目xml:

<style name="ActionButtonOverflow" parent="@style/Widget.AppCompat.ActionButton.Overflow" >
    <item name="android:tint">@color/yellow</item>
</style>

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorControlNormal">@color/red</item>
    <item name="android:actionOverflowButtonStyle">@style/ActionButtonOverflow</item>
</style>

谢谢。