我正在使用该项目universal-image-loader。我想知道如何获取在pagerActivity中显示的图像的大小?

我在ImagePagerActivity.java中添加了这两行(在imageLoader.displayImage(...){}之后)

imageView.getDrawable().getIntrinsicHeight()
imageView.getDrawable().getIntrinsicWidth()


但是结果是0和0。

我还尝试在ImagePagerActivity.java中使用它(我将getImageSizeScaleTo更改为ImageLoader中的public):

ImageSize targetSize = imageLoader.getImageSizeScaleTo(imageView);


但是尺寸始​​终是宽度:540高度:960,而我的图像却没有相同的尺寸。

最佳答案

您可以使用以下方法获得图像尺寸

 // 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();

关于java - 在PagerActivity中的 ImageView 中调整图像大小,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13996317/

10-17 01:23