I'm trying to use a .9.png file in Image composable as :
Image(
painter = painterResource(id = R.drawable.shadow_faq),
contentDescription = "Faq card 1",
modifier = Modifier
.constrainAs(imgGeneral) {
top.linkTo(glImgGeneralTop)
bottom.linkTo(glImgBottom)
start.linkTo(glImgLeft)
end.linkTo(glImgRight)
height = Dimension.fillToConstraints
width = Dimension.fillToConstraints
}
)
But on doing this I get a render problem that says java.lang.IllegalArgumentException: Only VectorDrawables and rasterized asset types are supported ex. PNG, JPG
How do I use a .9.png file with Jetpack Compose?
Update: Starting with 1.0.0-rc02
and accompanist 0.14.0
you can use the coil-compose version:
Image(
rememberImagePainter(ContextCompat.getDrawable(context,R.drawable.xxx)),
contentDescription = "Faq card 1",
)
Previous deprecated answer:
You can use the DrawablePainter
from Accompanist that returns a Painter
which draws an Android Drawable
.
Image(
rememberDrawablePainter(drawable = ContextCompat.getDrawable(context,R.drawable.xxxx) ),
contentDescription = "Faq card 1"
)