Thread
#compose
    Paul Woitaschek

    Paul Woitaschek

    1 year ago
    How do you handle image resources in compose? I have a xml vector that has 4 different colors I need to change at runtime. Using the old xml stuff I'd create a context theme wrapper that wraps a theme and then fetch the drawable. Is there any good solution for compose? The only "workaround" I've found is to do that inside compositon local provider:
    CompositionLocalProvider(LocalContext provides LocalContext.current.withTheme(R.style.MyTheme)) {
              Image(
                modifier = Modifier.align(Alignment.TopEnd),
                painter = painterResource(id = R.drawable.my_image), contentDescription = null
              )
            }
    Adam Powell

    Adam Powell

    1 year ago
    @Nader Jawad
    Nader Jawad

    Nader Jawad

    1 year ago
    We have an experimental API for AnimatedImageVector which is the equivalent to AnimatedVectorDrawable but in compose. Internally it supports an optional lookup mapping to override the default property for any named path or group. We're still iterating in this space and have not exposed it externally yet so the solution you have currently is probably the easiest way to support this case for now.
    Paul Woitaschek

    Paul Woitaschek

    1 year ago
    Looking forward towards this, it's good the hear that it's being evaluated.