在工具栏中将图标颜色更改为深黑色
change icon color to dark black in toolbar
我想将工具栏中的图标颜色更改为黑色十六进制代码 #000000 我该怎么做
注意 showAsAction 设置为 allways
这是我的代码
工具栏:-
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/tab_top"
app:menu="@menu/top_navigation"
android:layout_alignParentTop="true">
</androidx.appcompat.widget.Toolbar>
菜单:-
<?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/nav_following"
android:icon="@drawable/ic_baseline_following_24"
android:title=""
android:enabled="true"
app:showAsAction="always"
android:iconTint="@android:color/black">
</item>
</menu>
风格:-
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
here is the result im getting as we can see the icon is not black but it is dark grey
尝试
<androidx.appcompat.widget.Toolbar
...
android:tint="@android:color/black"
/>
我想将工具栏中的图标颜色更改为黑色十六进制代码 #000000 我该怎么做
注意 showAsAction 设置为 allways 这是我的代码
工具栏:-
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/tab_top"
app:menu="@menu/top_navigation"
android:layout_alignParentTop="true">
</androidx.appcompat.widget.Toolbar>
菜单:-
<?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/nav_following"
android:icon="@drawable/ic_baseline_following_24"
android:title=""
android:enabled="true"
app:showAsAction="always"
android:iconTint="@android:color/black">
</item>
</menu>
风格:-
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
here is the result im getting as we can see the icon is not black but it is dark grey
尝试
<androidx.appcompat.widget.Toolbar
...
android:tint="@android:color/black"
/>