Glide图片加载库,减少图片OOM问题;
导入
dependences{
implementation "com.github.bumptech.glide:glide:4.4.0"
annotationProcessor "com.github.bumptech.glide:compiler:4.4.0"
//包含 OkHttp3 集成库,Glide 自动开始使用 OkHttp 来加载图片
implementation "com.github.bumptech.glide:okhttp3-integration:4.4.0"
}
v4使用
- 与v3 增加了RequestOptions处理占位符,图片缩放方式,可复用
RequestOptions options = new RequestOptions()
.placeholder(colorDrawable)
.centerCrop();
Glide.with(mContext)
.load(url)
.apply(options)
.transition(DrawableTransitionOptions.withCrossFade())
.into(ivImage)
;
Proguard
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
本文介绍Glide图片加载库的使用方法,包括减少OOM问题的策略、依赖配置、v4版本新特性如RequestOptions的使用及过渡动画设置等。同时提供Proguard配置避免混淆问题。
1448

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



