[英]How to change color of icons in bottom app bar
我想更改底部應用欄中圖標的顏色。 我是第一次使用底部的應用程序欄,所以我沒有任何先驗知識。 具有底部應用欄的 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,但它沒有改變..任何幫助將不勝感激
你可以試試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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.