Glide使用详细标注
Android Studio用户
使用glide首先是builde.gradle添加依赖
compile 'com.github.bumptech.glide:glide:3.7.0'
eclipse用户可以glide提供jar文件,提供下载链接
https://github.com/kekegdsz/glide/blob/master/glide-3.7.0.jar
使用很简单,这是详细标注
//Glide使用
Glide.with(this)
.load(R.drawable.image) //设置要加载的内容
.placeholder(R.color.loading_color)//设置加载中的图片
.error(R.mipmap.ic_launcher) //设置加载出错时显示的图片
.priority(Priority.NORMAL) //设置请求加载优先级,Priority 里面是使用枚举的形式的
// .animate() //设置资源加载完成后的动画,不包矿从内存取出
// .dontAnimate() //移除默认淡入淡出动画
.crossFade() //加入默认的淡入淡出动画效果
// .crossFade(100) //设置默认淡入淡出动画的持续时间
//加载监听
.listener(new RequestListener<Integer, GlideDrawable>() {
@Override
public boolean onException(Exception e, Integer model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, Integer model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
})
.centerCrop() //缩放图片 fitCenter
.diskCacheStrategy( DiskCacheStrategy.NONE ) //设置是否跳过磁盘缓存 枚举类型all:缓存源资源和转换后的资源 none:不作任何磁盘缓存 source:缓存源资源 result:缓存转换后的资源
.skipMemoryCache(false) //设置是否跳过内存缓存
// .override(100,100) //设置加载宽高
.into(imageView); //加载容器