I mean ways other than using vectorResource(id = ...) (this confuses me with constant calls to context, resources, and other things).
I ask this because i see that we can make TextStyles, Shapes, Colors and Strings without smthngResource using.
As example iconAccent = Color(context.getColor(R.color.iconAccent))
Edit 1:
I found Bitmap.asImageAsset() method, it doesn't work in my case because vectors, but may be useful for somebody.
Edit 2:
I get the result by this way:
val group = ContextCompat.getDrawable(context, R.drawable.icon_group) as VectorDrawable
DrawableCompat.setTint(group, context.getColor(R.color.foregroundMain))
group = group.toBitmap().asImageBitmap()
DrawableCompat.setTint needed to correctly paint icons with theme color (we don't need it with vectorResource(id = ...) because it correctly take colors from fillColor property)
But it's crutch and if you know any other way - please write it. Believe compose developers will take into consideration this problem.
Yes!
ImageVector.vectorResource(R.drawable.ic_remove_circle)
it doesnt need Context.
You can use this tool (Svg2Compose : https://github.com/DenisMondon/Svg2Compose) to convert a Vector Drawable into an ImageVector.
So that you will be able to call directly:
Icons.YOUR_ICON
instead of:
vectorResource(R.drawable.your_icon)
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