https://kotlinlang.org logo
#compose
Title
# compose
b

Bryan Herbst

03/09/2021, 7:33 PM
Is there any high level guidance for defining vector drawables in a Compose world? Material defines them as paths in Kotlin files, but we of course still have the ability to define them as vector drawable resources. I’m assuming there’s at least some performance gain in defining them in Kotlin as paths and doing so also enables multiplatform support, but is there a meaningful benefit for an Android-only application?
t

tad

03/09/2021, 7:54 PM
It will save you some miniscule amount of time in aapt, and some runtime costs for converting those resources into ImageVector objects.
n

Nader Jawad

03/09/2021, 7:54 PM
Compose's vector graphics APIs are more generic and decouple the serialization from the rendering. This differs from VectorDrawable in the fact the parsing from the compiled xml format and drawing are coupled together.
💯 2
t

tad

03/09/2021, 7:56 PM
I actually repurposed the material generator code in our Gradle build to convert some FontAwesome icons, I should make that a plugin
You basically drop SVGs in
src/main/icons
and get generated Kotlin
b

Bryan Herbst

03/09/2021, 7:58 PM
Thanks! Would love to see an SVG -> ImageVector built into Studio as well alongside the existing SVG -> Vector drawable
👍 2
I’ll take a peek at Material’s because I’d love to have that automated using our icon library
6 Views