I am converting SVG to vector asset by importing it to android studio. How can I draw that vector to canvas with jetpack compose. The only option I see is drawImage, which only takes ImageBitmap. But this is a vector and not a bitmap, so is there a way to just draw ImageVector.
val logoVector: ImageVector = ImageVector.vectorResource(id = R.drawable.diasyst_logo)
You can wrap your ImageVector into a VectorPainter, which is able to render to the standard compose Canvas.
val vector = ImageVector.vectorResource(id = R.drawable.ic_launcher_foreground)
val painter = rememberVectorPainter(image = vector)
Canvas(modifier = Modifier.fillMaxSize()) {
with(painter) {
draw(painter.intrinsicSize)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With