[英]How to change color of icons in bottom app bar
I wanted to change the color of icons in the bottom app bar.我想更改底部应用栏中图标的颜色。 I am using the bottom app bar for the first time so I don't have any prior knowledge of it.
我是第一次使用底部的应用程序栏,所以我没有任何先验知识。 The code of the XML file having bottom app bar is below
具有底部应用栏的 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>
The menu file used in this is below这里使用的菜单文件如下
<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>
I wanted the color o the icon to change to primaryColor but it is not changing..Any help would be appreciated我希望图标的颜色更改为primaryColor,但它没有改变..任何帮助将不胜感激
You can try on menu.xml你可以试试menu.xml
Find the detail on link.在链接上找到详细信息。 (image)
(图片)
<?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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.