Questions tagged [coil]

For questions about the Coil Android library, not generic coils

Coil is a fast, lightweight, easy to use and modern image loading library for Android backed by Kotlin Coroutines.
Coil is an acronym for: Coroutine Image Loader.
The library is currently developed and manteined by Instacart, and is under the Apache License, Version 2.0.

References

148 questions
6
votes
2 answers

Variable ImagePainter on Jetpack Compose

I'm working on an Android app using Jetpack Compose 1.0.0 and I'm trying to make a composable that uses a nullable image URL string and, if it's null, it will show a placeholder with painterResource and, if it's not null, it will display the actual…
Matheus Dias
  • 115
  • 1
  • 9
5
votes
2 answers

Coil image caching not working with Jetpack Compose

I am using coil(version 2.1.0) to load images from URL. When there is network connection, the images are loading fine. However, when there is no network connection, the images are not being pulled from the cache as I expected them. Here's a block of…
5
votes
1 answer

Coil unit testing - how to do this?

Is it possible to mock coil network level when unit testing? With MockWebServer? Or test it somehow else? I can't find information on the Internet about it.
Vladimir Fisher
  • 3,090
  • 2
  • 17
  • 23
5
votes
1 answer

how to make Compose Preview display image/vector resources loaded from web?

I use Coil to load .svg resources from the web, for example: @Composable fun Widget(modifier: Modifier = Modifier) { AsyncImage( modifier = Modifier.fillMaxSize(), model = ImageRequest.Builder(LocalContext.current) …
5
votes
1 answer

jetpack Compose with Coil not loading URL images

New to Jetpack Compose and Coil, but not new to Android or Java/Kotlin. I'm not able to show images from a URL...Something basic missing? I took the Google/Android tutorial from (https://developer.android.com/jetpack/compose/tutorial) and added to…
Martin
  • 4,711
  • 4
  • 29
  • 37
5
votes
4 answers

Create a PDF Viewer in Jetpack Compose using PdfRenderer

I'm trying to create a PDF viewer composable using the PdfRenderer and Coil for loading the bitmaps into a LazyColumn. This is what I got so far: @Composable fun PdfViewer( modifier: Modifier = Modifier, uri: Uri, verticalArrangement:…
Filippo Vigani
  • 904
  • 1
  • 9
  • 22
5
votes
1 answer

Android:Cache Validity for an Image using coil in jetpack

I am facing issue in setting validity for Cache in android jetpack using coil. What I Need: In Android Jetpack compose, I need to download an SVG image from the Url and store it to the cache. But the cache should store the image only for 20 seconds.…
4
votes
1 answer

Compose - image recomposition

In my view model I have: var uri = savedStateHandle.getStateFlow("uri", Uri.EMPTY) private set In my view: val uri by viewModel.uri.collectAsState() Image( painter = rememberAsyncImagePainter( …
RCH
  • 1,247
  • 1
  • 11
  • 16
4
votes
1 answer

How to load image using AsyncImage in jetpack compose with GrayScale transformation?

I am unable to achieve the grayscale transformation. Current code to load Image. AsyncImage( model = ImageRequest.Builder(LocalContext.current) .data(url) .crossfade(true) .build(), contentDescription = "", …
Abhimanyu
  • 11,351
  • 7
  • 51
  • 121
4
votes
1 answer

Kotlin AsyncImage Coil not caching images properly, keeps reloading each time

I'm using the Coil dependency, so I can harness AsyncImage. This is how I'm displaying my images: AsyncImage( model = ImageRequest.Builder(LocalContext.current) .data(img) .crossfade(true) …
Sam Chahine
  • 530
  • 1
  • 17
  • 52
4
votes
1 answer

Rounded corner only at top of image AysncImage Coil

I'm using the new AysncImage loader for compose inside a Box. The Box itself has a RoundedCornerShape. I have also added a RoundedCornerShape for the AsyncImage with the following values Box( modifier = modifier …
4
votes
1 answer

Prioritise local cache over Network in Coil

I am using Coil with Jetpack compose. I noticed that in my LazyColumn items the images that load using coil(downloaded from the network) load faster when the device is offline ( this is once the images are cached of course ). When the device is…
Anudeep Ananth
  • 955
  • 1
  • 8
  • 30
3
votes
1 answer

Image isn't being loaded by Coil Kotlin Jetpack Compose

I have this image I want to load, I am using coil in jetpack compose to try and load it yet it didn't load and just gave me an empty composable. Whenever I try to load a different image from any other website it works, yet when I use the same…
Sofa44
  • 45
  • 5
3
votes
2 answers

Coil placeholder not showing if vectorpainter is used in jetpack compose

I am using the following code to display an image. AsyncImage( model = createImageUrl(audio.image_path), contentDescription = "Song Artwork", modifier = Modifier.fillMaxHeight() …
3
votes
0 answers

AsyncImage in LazyColumn Kotlin Compose

I have a list of photos from the internet and I want to load them into a LazyColumn. The problem is that some of them are loading faster than others so the photos appear in random order. Here is the code: val state =…
1
2
3
9 10