Search code examples
androidandroid-vectordrawable

Icons brooken and see like they are grayed out


I have a strange bug.

I have image as vector asset. It is created correct and see like:

enter image description here

I'm using it like menu icon on drawer:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:checkableBehavior="single">
        <item
            android:id="@+id/about"
            android:icon="@drawable/ic_about_us"
            android:title="@string/navigation_about" />
    </group>
</menu>

But in device it looked broken:

enter image description here

Do you see images on the background? It's vector assets too, but they works fine. I place it from code.

I have the similar problem with ViewPager icons. It seems like only icons are broken. So i have two vector assets:

enter image description here

enter image description here

I set this icons two different way(specially):

layout_tab.getTabAt(0)?.icon = activity?.getDrawable(R.drawable.ic_type_bird)
layout_tab.getTabAt(1)?.setIcon(R.drawable.ic_hints)

And then i see:

One:

enter image description here

Two:

enter image description here

What is going on, why my assets broken?


Solution

  • Your assets are not broken, it is just that the navigation drawer automatically applies a color filter to the icons which makes them appear gray. It is similar for the tabbar (as it is trying to show the state)

    The answer here shows how to stop this