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

Jeremy

02/15/2021, 4:44 PM
vectorResource
was deprecated with recommendation to use
painterResource
which creates Painter. How to convert
Painter
to
ImageVector
?
a

Alex Bieliaiev

02/15/2021, 4:52 PM
Why do you need
Painter
 to 
ImageVector
conversion?
j

Jeremy

02/15/2021, 4:53 PM
What is the correct new way to load ImageVector?
a

Alex Bieliaiev

02/15/2021, 4:54 PM
With the new
painterResource
you're supposed to use
Image(painter = painterResource(R.drawable.drawable_id))
1
1
s

Shabinder Singh

02/24/2021, 8:50 PM
found it!
j

jaqxues

02/24/2021, 9:02 PM
For example
Icons.Default.SomeIcon
still is a Vector Image. I had a list of screens where each screen had an Icon (either a drawable resource, or a built-in compose icon). This no longer works since painterResource returns a Painter, the other one still is a vector Image. So icon would have to be either a Painter or a VectorImage. A way to convert between those two would indeed be nice, so I dont have
if icon is painter Icon(painterResource = icon) else Icon(imageVector = icon)
Not the way I am doing it, but you get the gist.
3 Views