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:
And this is how that icon should be actually displayed:
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
)
Honestly, I don't think the accepted answer is the right thing to do. Icons tint automatically to the necessary contextual color.
If you want to show an icon without tinting, I'd suggest to use an Image instead:
Image(
painter = painterResource(id = R.drawable.ic_google_logo),
contentDescription = "Google Button"
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With