'How to display .svg Image URL in JetPack Compose? [duplicate]
I have svg image Url, I want to display the image in Jetpack Compose.
Solution 1:[1]
You can use the Coil SVG extension.
Add the dependencies in your build.gradle
implementation("io.coil-kt:coil-compose:2.0.0")
implementation("io.coil-kt:coil-svg:2.0.0")
Then, add it to your call..
@Composable
fun SvgImageSample() {
val painter = rememberAsyncImagePainter(
model = ImageRequest.Builder(LocalContext.current)
.decoderFactory(SvgDecoder.Factory())
.data("https://upload.wikimedia.org/wikipedia/commons/d/d7/Android_robot.svg")
.size(Size.ORIGINAL) // Set the target size to load the image at.
.build()
)
Image(
painter = painter,
contentDescription = null
)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | nglauber |