Reputation: 7559
I have set <ImageView />
height to wrap_content
. I am adding this layout in recycler adapter
There will be around 10 images
all images are set to wrap_content
.
Is there any way to get the height of image rendered by Glide.
I am using this, but its returning the screen dimensions and not image dimensions
.
Glide.with(context).load(imgpth).placeholder(R.drawable.bg_loading)
.error(R.drawable.bg_loading).into(imageProdctBanner).getSize(new SizeReadyCallback() {
@Override
public void onSizeReady(int width, int height) {
Log.e("width","wdthheight "+width+" : "+height);
}
});
I need this to set height of recyclerView.
int totalItems= cardsRecyclerAdapter.getItemCount();
ViewGroup.LayoutParams params=rvCards.getLayoutParams();
params.height= heightOfImageView *totalItems;
rvCards.setLayoutParams(params);
Upvotes: 6
Views: 6344
Reputation: 4442
use onResourceReady()
method instead
Glide.with(getContext().getApplicationContext())
.asBitmap()
.load(path)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap bitmap,
Transition<? super Bitmap> transition) {
int w = bitmap.getWidth();
int h = bitmap.getHeight()
mImageView.setImageBitmap(bitmap);
}
});
Upvotes: 7