Android图片加载与缓存开源框架: Android Glide

Android Glide是一个开源的图片加载和缓存处理的第三方框架。Android Glide使自身内部已经实现了缓存策略,使得开发者摆脱Android图片加载的琐碎事务,专注逻辑业务的代码。Android Glide使用便利,短短几行简单明晰的代码,即可完成大多数图片从网络(或者本地)加载、显示的功能需求。

使用Android Glide,需要先下载Android Glide的库,Android Glide在github上的项目主页:
https://github.com/bumptech/glide

compile files('src/main/libs/glide-3.6.0.jar.jar')

或者直接在app/build.gradle文件中添加dependencies:

compile 'com.github.bumptech.glide:glide:3.7.0'

在实际项目中的使用如下:

ImageView img = (ImageView) convertView.findViewById(R.id.imageView);  
Glide.with(mActivity).load(img_url).centerCrop()  
/* 
 * 缺省的占位图片,一般可以设置成一个加载中的进度GIF图 
 */  
.placeholder(R.drawable.loading).crossFade().into(img);  

猜你喜欢

转载自blog.csdn.net/fengchi863/article/details/80049716