PagerActivity中的imageview中的大小图像

时间:2012-12-21 19:50:32

标签: java android universal-image-loader

我正在使用这个项目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而我的图像尺寸不一样。

1 个答案:

答案 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();