且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

之后如何在Android中加载低质量然后高质量的图像(就像WhatsApp的配置文件图像一样)

更新时间:2023-02-13 22:58:40

我找到了 Glide 的解决方案. 您可以指定要作为缩略图加载的低分辨率图像.您只需要:

I found solution with Glide. You can specify low resolution image to be loaded as thumbnail. All you need is:

private void loadImageThumbnailRequest() {  
// setup Glide request without the into() method
DrawableRequestBuilder<String> thumbnailRequest = Glide
    .with( context )
    .load( yourData.getLowQualityLink() );

// pass the request as a a parameter to the thumbnail request
Glide
    .with( context )
    .load( yourData.getHdUrl() )
    .thumbnail( thumbnailRequest )
    .into( imageView );
}

来源此处