試試這個代碼。這將幫助你..
Glide.with(this).load(photo_url)
.crossFade()
.thumbnail(0.5f)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(R.drawable.plaeholder_image)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
imageView.setImageDrawable(resource);
return false;
}
})
.into(imageView);
請使用佔位符圖像,而不是顏色。您將能夠使用可繪製的純灰色圖像作爲佔位符圖像。
是否確定你沒有在xml中設置imageview的背景 –
不,我沒有使用任何背景在xm文件中的imageview。 ' ' 這是我用於imageView的。 –
嘗試刪除scaleType或adjustViewBounds,你確定你需要這2個屬性 –