is a vector drawable. This code crashes on API 21 with
android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/ic_accessory_arrow.png from xml type xml resource ID #0x7f0800e3
exception. So, what should I do for older SDKs? Write it like that?
Copy code
// Random number here: I don't even know which API versions implicitly convert vector drawables to png
if (Build.VERSION.SDK_INT > 23) {
Icon(vectorResource(…))
} else {
Icon(imageResource(…))
}
n
Nader Jawad
12/16/2020, 10:32 PM
With the latest alpha release we have a
painterResource
API that will automatically load an
ImagePainter
or a
VectorPainter
👍 1
Nader Jawad
12/16/2020, 10:33 PM
And should not require having to do a manual API level check. That is if a certain configuration has the resource identifier as a vector drawable it will be parsed as a VectorPainter but if it is a rasterized image (ex png/jpg) it will be loaded as a ImagePainter