Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing a Progress bar while loading image using Coil?

How to show a progress bar while fetching image from URL in Coil.?

like image 609
Unaisul Hadi Avatar asked Mar 31 '26 23:03

Unaisul Hadi


2 Answers

Use ImageRequest.Listener

Example:

val imageRequest = ImageRequest.Builder(context)
    .data(url)
    .listener(
        onStart = {
            // set your progressbar visible here
        },
        onSuccess = { request, metadata ->
            // set your progressbar invisible here
        }
    )
    .build()

imageLoader.enqueue(request)
like image 158
uragiristereo Avatar answered Apr 02 '26 12:04

uragiristereo


If you are creating app with jetpack compose then you don't need to do manual stuff,

you can use the builtin SubcomposeAsyncImage provided by the library from version 2.0.0-rc01

SubcomposeAsyncImage(
    model = image,
    contentDescription = "",
    loading = { 
        CircularProgressIndicator(color = Color.Black) 
    },
)
like image 44
Pratik Fagadiya Avatar answered Apr 02 '26 12:04

Pratik Fagadiya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!