I have a menu:
<?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/menu_search"
android:icon="@drawable/search"
android:iconTint="@color/iconBackground"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="ifRoom|collapseActionView" />
<item
android:id="@+id/menu_info_bar"
android:icon="@drawable/search_barcod"
android:iconTint="@color/iconBackground"
app:showAsAction="always" />
<item
android:id="@+id/menu_filter_list"
android:icon="@drawable/select_auction"
android:iconTint="@color/iconBackground"
app:showAsAction="always" />
</menu>
which is added to the ToolBar
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBar"
style="@style/Widget.MaterialComponents.Toolbar.Primary"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/background"
android:visibility="visible"
app:menu="@menu/menu_main_top"
app:navigationIcon="@drawable/logo"
app:navigationIconTint="@color/iconBackground"
app:title="@string/app_name" />
The colors of iconBackground are set differently for light and dark themes.
for a light theme
<color name="iconBackground">#FFFFFF</color>
for a dark theme
<color name="iconBackground">#292929</color>
But for some reason, the color of the icons in the menu on the Toolbar
is always white, while navigationIcon changes its color.
What could be the reason?
At the same time, the xml menu is fine
Since no one offered anything, it made it easier. Translated all the icons into Vector set (xml) vector format and assigned the color of the icon Background in the XML file itself