[英]Glide not loading image properly
這里的圖像沒有完全加載。 我不知道為什么。 不知何故半占位符和不知何故的半圖像。 有時它加載沒有任何問題。
我在用
implementation 'com.github.bumptech.glide:glide:3.7.0'
這是我的代碼
val headerView = nav_view.getHeaderView(0)
Glide.with(act).load(userdata.image).placeholder(R.drawable.ic_male).thumbnail(0.2f).into(headerView.imgNavDp)
XML
<de.hdodenhof.circleimageview.CircleImageView
android:layout_marginLeft="@dimen/dim_5"
android:id="@+id/imgNavDp"
android:layout_width="@dimen/dim_76"
android:layout_height="@dimen/dim_76"
android:elevation="@dimen/dim_10"
android:layout_gravity="center_vertical"
app:srcCompat="@mipmap/ic_launcher_round" />
有一種解決方法可以處理Glide中的加載錯誤問題
導入它,並將compile sdk版本保持為27
compile 'com.github.bumptech.glide:glide:3.8.0'
然后使用此代碼
Glide.with(context)
.load(userdata.image)
.placeholder(R.drawable.ic_male)
.error(R.drawable.imagenotfound)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
// log exception
Log.e("TAG", handle error case", e);
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
Log.e("TAG", handle success case here", e);
return false;
}
})
.into(headerView.imgNavDp);
並從xml
刪除它
app:srcCompat="@mipmap/ic_launcher_round"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.