How can I get a composable preview to correctly ti...
# compose
c
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.
z
I think you’d have to get the tint out of the theme, and then manually pass the tint to the
ImageView
.
t
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
I don't know because I'm letting the user of the composable pass in an Int of a
@DrawableRes
t
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.