Android Glide: Show a blurred image before loading actual image

后端 未结 8 1092
谎友^
谎友^ 2021-02-01 06:37

I am developing an Android app which displays full screen images to the user. Images are fetched from the server. I am using Glide to show the image. But I want to display a ver

8条回答
  •  北海茫月
    2021-02-01 06:52

    glide has a direct way of doing this :

    val thumbnailRequest = Glide.with(this)
            .load("https://picsum.photos/50/50?image=0")
    
    Glide.with(this)
            .load("https://picsum.photos/2000/2000?image=0")
            .thumbnail(thumbnailRequest)
            .into(imageThumbnail)
    

    from the blog:

    Thumbnails are a dynamic placeholders, that can be loaded from the Internet. Fetched thumbnail will be displayed until the actual request is loaded and processed. If the thumbnail for some reason arrives after the original image, it will be dismissed.

提交回复
热议问题