How to avoid tinting Icon with painterResource().It paints my vector in Black

Viewed 1852

Okay so I have created my own .SVG vector icon and imported it as an XML in Android Studio. Now I'm trying to create an Icon using that same vector. However when I specify that vector in painterResource() it paints it in Black color. And my original SVG has multiple colors instead. Any raesons why is this happening?

Icon(
     painter = painterResource(id = R.drawable.ic_google_logo),
     contentDescription = "Google Button"
    )

When I add that icon this is what I see: enter image description here

And this is how that icon should be actually displayed: enter image description here

1 Answers

The Icon applies a default tint (LocalContentColor.current.copy(alpha = LocalContentAlpha.current))

Use tint= Color.Unspecified to avoid it:

Icon(
     painter = painterResource(id = R.drawable.ic_google_logo),
     contentDescription = "Google Button",
     tint= Color.Unspecified
    )
Related