简体   繁体   English

在PagerActivity中的图像视图中调整图像大小

[英]size image in an imageview in PagerActivity

I am using this project universal-image-loader .I would like to know how can I get the size of an image displayed in the pagerActivity? 我正在使用这个项目通用图像加载器 。我想知道如何获得在pagerActivity中显示的图像的大小?

I added this two line in ImagePagerActivity.java (after imageLoader.displayImage(...){}) 我在ImagePagerActivity.java中添加了这两行(在imageLoader.displayImage(...){}之后)

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

But the result is 0 and 0. 但是结果是0和0。

I also tried to use this in ImagePagerActivity.java (I change the getImageSizeScaleTo to public in ImageLoader): 我还尝试在ImagePagerActivity.java中使用它(我将getImageSizeScaleTo更改为ImageLoader中的public):

ImageSize targetSize = imageLoader.getImageSizeScaleTo(imageView);

But the size is always width:540 height:960 whereas my images don't have the same size. 但是尺寸始​​终是宽度:540高度:960,而我的图像却没有相同的尺寸。

You can get the image size by using the following methods 您可以使用以下方法获得图像尺寸

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

Or It might help, you can try this : 或者它可能会有所帮助,您可以尝试以下操作:

  int imageWidth = imageObj.getMeasuredWidth();
  int imageHeight = imageObj.getMeasuredHeight();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM