picasso是Square公司开源的一个Android图形缓存库,地址http://square.github.io/picasso/,可以实现图片下载和缓存功能。github地址https://github.com/square/picasso
下载
在build.gradle文件添加
compile 'com.squareup.picasso:picasso:2.5.2'
使用
初始化
方法一(推荐,并自己进行封装)
Picasso picasso=Picasso.with(context);
picasso.load(url);
方法二
Picasso..with(context).load(url);
参数详解
//此方法适用于不设置大小,自动进行适配
Picasso.with(context) //
.load(url)// 加载的URL
.placeholder(R.mipmap.ic_launcher) //loading期间显示的图片
.error(R.mipmap.ic_launcher) //加载失败显示的图片
.fit() //适配
.tag(context) //
.into(holder.imageView);//需要显示加载图片的ImageView
//此方法适用于设置图片大小,不进行适配
Picasso.with(context)
.load(url)
.placeholder(R.mipmap.ic_launcher)
.error(R.mipmap.ic_launcher)
.resizeDimen(R.dimen.img_width, R.dimen.img_width)//此处给的是一个资源dimen的id,
.centerInside()
.tag(context)
.into(holder.imageView);
Picasso是由Square公司开源的一款Android平台上的图片下载与缓存库。它支持图片的加载、适配、尺寸调整等功能,并提供了丰富的API来方便地设置加载过程中的占位图和错误图等。
1万+

被折叠的 条评论
为什么被折叠?



