Android:更改菜单项中的图标颜色

问题描述 投票:0回答:1

我已经阅读了与在该主题上发现的许多类似文章,并且所有提议的解决方案似乎都没有用。

我有一个带有图标的菜单项= ic_btn_speak_now

<menu 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">

    <item
        android:id="@+id/speech"
        android:icon="@android:drawable/ic_btn_speak_now"
        android:title="Speak name"
        android:onClick="speechRecognition"
        app:showAsAction="always" />
    <item
        android:id="@+id/search_checklist"
        android:icon="@android:drawable/ic_menu_search"
        android:onClick="searchChecklist"
        android:title="@string/search_checklist"
        app:showAsAction="always" />

它在以下布局中显示AppBar

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".ChecklistActivity">

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@id/locationInfoContraintLayout"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tabAppBarLayout" />

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/tabAppBarLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tabLayoutView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            app:tabMode="scrollable" />

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

图标显示太暗。我想将其更改为白色。这是目前的样子...

enter image description here

如何将其更改为白色?还是比这更明亮的东西?用户甚至看不到扬声器项目在那儿。我尝试将色调设置为白色,并且可以在Studio中使用,但在我的AVD或实际设备中没有任何更改。

android
1个回答
0
投票
您可以使用“ app:itemIconTint”属性。
© www.soinside.com 2019 - 2024. All rights reserved.