Reputation: 1246
I using Glide lib for load photo from url to show on ImageView.But this Photo have multiple size, i want before updating the ImageView then placeholder show with size equal size Image from URL.
Like this:
This is my code:
Glide.with(context)
.load(url)
.override((int) context.getResources().getDimension(R.dimen._180sdp), (int) context.getResources().getDimension(R.dimen._300sdp))
.fitCenter()
.bitmapTransform(new RoundedTransformation(context, (int) context.getResources().getDimension(R.dimen._10sdp)))
.error(defaultImageResId)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
progressBar.setVisibility(View.INVISIBLE);
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
progressBar.setVisibility(View.INVISIBLE);
return false;
}
})
.into(imageView);
How can do it?
Upvotes: 5
Views: 2532
Reputation: 482
You need to get the image dimensions from the server along with URL and use it to resize the place holder image.
Glide
.with(context)
.load(imageUrl)
.override(width, height) // resizes the image to these dimensions (in pixel)
.into(imageViewResize);
Upvotes: 2