recompose
recompose copied to clipboard
Image: imageResource vs. vectorResource
Currently a drawable
value in ImageView
will always be written as:
Image(imageResource(R.id.the_drawable), ...)
This works for drawable resources that are PNGs. But it fails if the drawable is a vector image. In that case it needs to be:
Image(vectorResource(R.id.the_drawable), ...)
From the XML alone we cannot know if the drawable is a vector resource or not. We could try finding the drawable (assuming default folders are used), but this fails if the resource is not in the app itself (e.g. provided by a library or a different module).
Alternatively the plugin in the IDE could try to figure out what kind of drawable is used - but this will only work in the plugin and not in the CI.
In general I am surprised to see Jetpack Compose force making this distinction unto the consumer. Wouldn't it be more convenient to provide a drawable resource to Compose and it can figure out itself what it is?