Display SVG with accompanist-coil with Jetpack Compose

Photo by Ehimetalor Akhere Unuabona on Unsplash
//Coil
implementation "com.google.accompanist:accompanist-coil:0.11.1"
implementation "io.coil-kt:coil-svg:1.1.1"
val weatherIcon = "https://vreme.arso.gov.si/app/common/images/svg/weather/clear_day.svg"
val imageLoader = ImageLoader.Builder(LocalContext.current)
.componentRegistry {
add(SvgDecoder(LocalContext.current))
}
.build()
CompositionLocalProvider(LocalImageLoader provides imageLoader) {
val painter = rememberCoilPainter(weatherIcon)
Image(
painter = painter,
contentDescription = null,
modifier = Modifier.size(200.dp)
)
...
...other composables
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store