Reputation: 2909
In my code I'm loading image from source into my ImageView. ScaleType of this image view is FIT_CENTER. My original image is far bigger than on screen. Is it possible to obtain width and height or scale ratio of image on screen? I can do it manually like based on orientation of image, calculate ratio of area that ImageView is in and ratio of image itself. After ratio I can assume which dimension is fitted (like width or height) and so on...
Is there any other easiest way to do it?
Upvotes: 3
Views: 2977
Reputation: 24453
There is another way to "auto-scale" your image. You should set the loaded bitmap as background of ImageView control instead of set as source. Hope this helps.
Upvotes: 0
Reputation: 3126
You can scale your image retaining aspect ratio by setting the adjustViewBound to true and scaleType to fitXY.
android:adjustViewBounds="true"
android:scaleType="fitXY"
Upvotes: 8
Reputation: 2881
hi set your scale type fitXY
like as this. android:scaleType="fitXY"
Upvotes: 0
Reputation: 16623
Use ImageView's
getDrawable().getIntrinsicHeight()
Taken from this related question.
Upvotes: 0