我已将<ImageView />
高度设置为wrap_content
。我在添加此布局recycler adapter
周围将10 images
所有图像设置为wrap_content
。
有没有办法获取Glide渲染的图像的高度。
我正在使用它,但是它返回的是屏幕尺寸,而不是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);
}
});
我需要这个来设置recyclerView的高度。
int totalItems= cardsRecyclerAdapter.getItemCount();
ViewGroup.LayoutParams params=rvCards.getLayoutParams();
params.height= heightOfImageView *totalItems;
rvCards.setLayoutParams(params);
使用onResourceReady()
方法代替
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);
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句