0

I am trying to set a menu icon programatically with setIcon() with a custom drawable. The drawable has multiple paths of different colors. However whenever I set the icon the style that is set as the theme of the activity:

<style name="ToolBarTheme" parent="Theme.MaterialComponents.Light.NoActionBar">

    <item name="colorPrimary">@color/grey_45</item>
    <item name="colorPrimaryVariant">@color/blue_03</item>
    <item name="colorOnPrimary">@color/blue_05</item>
    <item name="colorSurface">@color/blue_02</item>
    <item name="colorPrimaryDark">@color/blue_10</item>
    <item name="android:windowAnimationStyle">@null</item>
</style>

overrides each path's color and displays a single one instead. Specifically the item - @color/grey_45. When I removed it, instead of showing the items with the original drawable color, it shows it with a purple-ish tint.

How can I set the menu icon to a drawable that contains multiple colors?

This is the xml object where the menu is:

<com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigationView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent"
        app:itemActiveIndicatorStyle="@color/blue_10"
        app:itemRippleColor="@color/blue_10"
        app:menu="@menu/bottom_nav_menu" />

PS : I took a look at this link but they advice to use setTint() method which results in Icon being single colored.

Kristian
  • 165
  • 2
  • 16

0 Answers0