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 *;
}