Set visibility of progress bar gone on completion of image loading using Glide library

前端 未结 12 2035
栀梦
栀梦 2020-12-04 11:04

Hi I want to have a progress bar for image which will shown while image loading but when image loading will be completed I want to set it to gone. Earlier I was using Picass

12条回答
  •  醉酒成梦
    2020-12-04 11:37

    This is the best answer as it does not use any hack like setting visibility to get the desired output.

    Download a gif of progressbar and call it progressbargif and put it in the drawable folder.

            Glide.with(ctx)
                .load(url)
                .thumbnail(Glide.with(ctx).load(R.drawable.progressbargif))
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .error(R.drawable.image_unavailable)
                .crossFade(200)
                .into(iv);
    

    Once the url image is loaded, the thumbnail vanishes. The thumbnail vanishes immediately when the cached image is loaded.

提交回复
热议问题