Which library supports GIF files best for compose?
# compose
z
Which library supports GIF files best for compose?
c
z
Have you tried this? i cant seem to understand how to use
imageLoader
with compose
c
Basically you have to read both articles and combine them. But it should work like this:
Copy code
val imageLoader = ImageLoader.Builder(LocalContext.current)
    .componentRegistry {
        if (SDK_INT >= 28) {
            add(ImageDecoderDecoder(LocalContext.current))
        } else {
            add(GifDecoder())
        }
    }
    .build()

CompositionLocalProvider(LocalImageLoader provides imageLoader) {
    // now you can use the image painter
    Image(
        painter = rememberImagePainter("<https://www.example.com/image.gif>"),
        contentDescription = null,
        modifier = Modifier.size(128.dp)
    )
}
You should provide
LocalImageLoader
in your top level UI code, so the singleton loader will be used everywhere down in the Compose tree.
z
Awesome Tnx!
👍 1
148 Views