[英]size image in an imageview in PagerActivity
我正在使用這個項目通用圖像加載器 。我想知道如何獲得在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();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.