It looks like the only way to go about loading custom icons from Android Vector Resources in the res
folder is to do it within a @Composable
function using the vectorResource(R.drawable.myVectorName)
method.
This is great and all, but I like the syntax of fetching VectorAssets
for the Icon(asset: VectorAsset)
class, which looks like Icon(Icons.Default.Plus)
.
It looks like the vectorResource()
method uses an internal method called loadVectorResource()
, and the methods it uses to read the actual XML file composing the vector asset file are also internal.
How would I go about creating an object like MyAppIcons.Default.SomeIcon
in Jetpack Compose?
EDIT
So, I have sort-of found a solution. However, it would be nice to make my own extension/overloading of the built-in Icon()
function, but I'm not sure if there is a proper way to do this.