In my code I'm loading image from source into my ImageView. ScaleType of this image view is FIT_CENTER. My original image开发者_如何学Python 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?
You can scale your image retaining aspect ratio by setting the adjustViewBound to true and scaleType to fitXY.
android:adjustViewBounds="true"
android:scaleType="fitXY"
Use ImageView's
getDrawable().getIntrinsicHeight()
Taken from this related question.
hi set your scale type fitXY
like as this. android:scaleType="fitXY"
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.
精彩评论