Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AndroidX BottomAppBar navigation icon color

I've defined a bottom bar in a layout like that:

<com.google.android.material.bottomappbar.BottomAppBar
    android:id="@+id/bottomBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    app:navigationIcon="@drawable/ic_menu_black_24dp" />

The navigation icon is a generic icon generated from the "new vector drawable" wizard. Is there a way to apply a tint to it?

The bottom bar is not the activity action bar.

What I've tried so far:

  • applied a theme with an overridden textColorPrimary color
  • applied a theme with an overridden controlColorNormal color

If there's a solution that also works on icons supplied by loading a menu from XML (using inflateMenu() or replaceMenu()), that would be perfect.

like image 488
SpaceBison Avatar asked Oct 04 '18 11:10

SpaceBison


1 Answers

The navigation icon color is bases on colorControlNormal attribute.
You can override it using:

<com.google.android.material.bottomappbar.BottomAppBar
    android:theme="@style/ThemeOverlay.BottomAppBar"

with:

<style name="ThemeOverlay.BottomAppBar">
    <item name="colorControlNormal">@color/....</item>
</style>

enter image description here

like image 109
Gabriele Mariotti Avatar answered Nov 15 '22 17:11

Gabriele Mariotti