我正在使用这个项目universal-image-loader。我想知道如何获得pagerActivity中显示的图像大小?
我在ImagePagerActivity.java中添加了这两行(在imageLoader.displayImage(...){}之后)
imageView.getDrawable().getIntrinsicHeight()
imageView.getDrawable().getIntrinsicWidth()
但结果是0和0。
我也尝试在ImagePagerActivity.java中使用它(我在ImageLoader中将getImageSizeScaleTo更改为public):
ImageSize targetSize = imageLoader.getImageSizeScaleTo(imageView);
但尺寸总是宽度:540高度:960而我的图像尺寸不一样。
答案 0 :(得分:1)
您可以使用以下方法获取图像大小
// Getting the size of the Image inside the ImageView and The size will differ based
**// on the image you placed inside the ImageView
ImageView imageObj = (ImageView)findViewById(R.id.image_view_id);
int imageWidth = imageObj.getWidth();
int imageHeight = imageObj.getHeight();
int imageWidth = imageObj.getMeasuredWidth();
int imageHeight = imageObj.getMeasuredHeight();