0

我想更改底部应用栏中图标的颜色。我是第一次使用底部的应用程序栏,所以我没有任何先验知识。具有底部应用栏的 XML 文件的代码如下

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".NavigActivity">


    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorAccent">
        <com.google.android.material.bottomappbar.BottomAppBar
            android:id="@+id/bottom_app_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            app:backgroundTint="@color/colorAccent"
            app:navigationIcon="@drawable/ic_menu_black_24dp"
            app:menu="@menu/menu"
            app:buttonGravity="center_vertical"
            />
        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_add_black_24dp"
            app:layout_anchor="@id/bottom_app_bar"
            android:backgroundTint="@color/colorPrimary"

            app:maxImageSize="35dp"/>

    </androidx.coordinatorlayout.widget.CoordinatorLayout>
    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/content_frame"
 />

</RelativeLayout>

这里使用的菜单文件如下

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/home"
        android:title="Home"
        android:icon="@drawable/ic_home_black_24dp"
        app:showAsAction="ifRoom"
        />
    <item
        android:id="@+id/my_invoices"
        android:title="Invoices"
        android:icon="@drawable/ic_receipt_black_24dp"
        app:showAsAction="ifRoom"
        />
    <item
        android:id="@+id/notification"
        android:title="Notification"
        android:icon="@drawable/ic_notifications_black_24dp"
        app:showAsAction="ifRoom"
        />


</menu>

我希望图标的颜色更改为primaryColor,但它没有改变..任何帮助将不胜感激

4

1 回答 1

0

你可以试试 menu.xml

在链接上找到详细信息。(图片)

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="[URL]http://schemas.android.com/apk/res/android[/URL]"
    xmlns:app="[URL]http://schemas.android.com/apk/res-auto[/URL]">
    <item
        android:id="@+id/menu_color_change"
        android:title="Color Plate"
        app:showAsAction="ifRoom"
        android:icon="@drawable/ic_color_plate">
    </item>
    <item
        android:id="@+id/menu_other"
        android:title="Other"
        app:showAsAction="never"
        android:iconTint="@android:color/white"
        android:icon="@drawable/ic_color_plate">
    </item>
</menu>
于 2020-04-27T13:22:09.487 回答