1

I have an ImageView in my layout. Its width and height are both set to fill_parent. The scaleType is set to fitCenter. I am in landscape mode. So if I have a square src image, when scaled up it will display me two borders, on the left and on the right, which perfectly suits me. But how can I get the dimensions of these borders ? The dimensions of the bitmap won't help for sure, and the dimensions of the ImageView are equal to the screen's.

I have asked for intrinsicwidth but it seems to give me the width of the drawable before it has scaled up.

I have tried adjustViewBounds but the ImageView still fills all the parent.

Any idea ?

Thanks

Guillaume
  • 1,051
  • 1
  • 11
  • 15

2 Answers2

0

See my answer here Get drawable displayed size after scaling on how to calculate displayed size for FIT_CENTER scaleType.

And for the calculating the border dimensions just substract calculated value and divide by 2 from the imageView dimesnsions.

Community
  • 1
  • 1
SGal
  • 1,072
  • 12
  • 13
0

make a RectF to represent the original picture size, scale it with a matrix into a new RectF, then use this to find your dimensions.

tantonj
  • 434
  • 5
  • 18
  • How can I get the RectF representing the original size ? In fact I would avoid to call the bitmap if possible. – Guillaume Mar 07 '12 at 21:43