Is there a way to color an SVG with different colo...
# compose
r
Is there a way to color an SVG with different colors in Compose? Previously I used ContextThemeWrapper with a custom theme and in the SVG I set the fillColor to my custom attribute ( for example:
android:fillColor="?attr/ferryOutside"
) . This allowed me to reuse the same SVG for different colored images. I am wondering if there is a way to do this in Compose and maybe there is a better way? I need to use multiple colors in the SVG, it seems like LocalContentColor is not suitable for this use.
c
Seems like my question above could help you as well. 😄
But yeah, the colorFilter param on Image composable seems to work. but not sure if I should be including a BlendMode or something.
r
for single color this worked for me:
Copy code
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colors.ferryOutside)
ferryOutside = Color(0xff232350) But my problem is that the image has another color that I would like to draw with a different color, but I couldn't find a way to do this. Before Compose ContextThemeWrapper could set a custom style where I defined different attributes for my image and I would refer to them as attributes in the image. Then I could have multiple styles and change between them with ContextThemeWrapper.
220 Views