Hi, what is the proper way to paint a Vectorial im...
# compose
m
Hi, what is the proper way to paint a Vectorial images in the version dev07?
p
Copy code
@Composable
fun VectorImage(
    modifier: Modifier = Modifier.None,
    @DrawableRes id: Int,
    tint: Color = Color.Transparent
) {
    val vector = vectorResource(id)
    Container(
        modifier = modifier + LayoutSize(vector.defaultWidth, vector.defaultHeight)
    ) {
        DrawVector(vector, tint)
    }
}
is the way its been done most recently, not sure if that changed in dev07
m
thanks, but this is what I had in dev06, as I read now we have to use drawVector modifier. I have tried and this work but I need a "view" which doesn't need children
Copy code
@Composable
fun SimpleVector(@DrawableRes id: Int, tint: Color = Color.Transparent) {
    val vector = vectorResource(id)
    Container(
        width = vector.defaultWidth,
        height = vector.defaultHeight,
        modifier = drawVector(vector, tint)
    ) {
        Text("")
    }
}
This works for me but it is a hack
I need to use this modifier in a component which don't need children to get rid of this empty Text
it looks like VectorPainter will replace drawVector but i think thats for dev08
because that deprecation warning doesnt show up for me in AS
with dev07
m
ok, so I will have to wait to dev08
l
why do you need the empty text?
does something break without it?
m
because the container require a children
but I know this is really ugly
l
oh i forgot container was gross like that
in general this is not the case
just use
Box
it is the Container replacement, and there are no requirements on number of chuldren
Container will be deprecated in dev08
m
this is working like a charm
thanks guys