Thread
#compose
    c

    chris

    2 years ago
    How can I get a composable preview to correctly tint a vector/drawable in an
    AndroidView
    based on the theme that is wrapping it? I'm using an
    AndroidView
    so that I can use an
    ImageView
    because I'm being passed a
    @DrawableRes
    and I don't know if it will be a vector or a drawable.
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    I think you’d have to get the tint out of the theme, and then manually pass the tint to the
    ImageView
    .
    Timo Drick

    Timo Drick

    2 years ago
    Why do you not know if it is a vector or bitmap? I had a problem that on old devices my vectors got converted to bitmaps but i was able to deactivate this behaviour by set vectorDrawables.useSupportLibrary = true
    c

    chris

    2 years ago
    I don't know because I'm letting the user of the composable pass in an Int of a
    @DrawableRes
    Timo Drick

    Timo Drick

    2 years ago
    Ok i see. Many of the new material composables let the user specify an composable instead of an icon or an drawable. I like it be cause you get much more freedom as api user. Maybe you should consider doing the same. But of course i do not know you specific use case. Maybe it is not applicable there.