I'm using Glide to load an image from an API. I am using a gif to show loading before the image loads so initially I used specific 250dp of height of imageview and once the image loads properly, I'm setting the height as WRAP_CONTENT and scaletype of FIT_XY inside onResourceReady of glide listener. But here, sometimes image loads with its full height and other times when I scroll up it again loads the same image in same imageview with compressed height, it seems onResourceReady is getting executed the not all the times. `Glide.with(context)
.load(outerHits.getHits().get(position).get_source().getProfilePic())
.thumbnail(Glide.with(context).load(R.drawable.loading_gif3))
.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) {
LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
((ViewHolder6) holder).card_gallary1_img1.setLayoutParams(params);
((ViewHolder6) holder).card_gallary1_img1.setScaleType(ImageView.ScaleType.FIT_XY);
return false;
}
})
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.into(((ViewHolder6) holder).card_gallary1_img1);`
Xml is
<ImageView
android:id="@+id/card_gallary1_img1"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@color/white"
android:src="@drawable/no_image"/>