I have an image view which has an image inside and the image bounds are different that the bounds of the Imageview. How to get the bound of the image inside the Imageview in Android.
Asked
Active
Viewed 456 times
0
-
1Can you post your code plz ? – Maxouille Mar 06 '19 at 12:35
-
Possible duplicate of [Get the displayed size of an image inside an ImageView](https://stackoverflow.com/questions/12463155/get-the-displayed-size-of-an-image-inside-an-imageview) – devgun Mar 09 '19 at 18:45
2 Answers
0
You can access the size of the underlying image like this :
ih=imageView.getMeasuredHeight();//height of imageView
iw=imageView.getMeasuredWidth();//width of imageView
iH=imageView.getDrawable().getIntrinsicHeight();//original height of underlying image
iW=imageView.getDrawable().getIntrinsicWidth();//original width of underlying image
You can also fit your image to the ImageView size with :
android:scaleType="fitxy"
android:adjustViewBounds="true"
For more info on the scaleType look at : https://thoughtbot.com/blog/android-imageview-scaletype-a-visual-guide
Best

Maxouille
- 2,729
- 2
- 19
- 42