Android如何用矩阵获取imageview的边界

saa*_*az1 3 android matrix scale bounds imageview

我有一个将scaletype设置为matrix的ImageView,并希望在转换矩阵后得到一个带有图像边界的Rect.

我怎么得到这样的直肠?谢谢.

Tom*_*ski 10

ImageView imageView = (ImageView)findViewById(R.id.imageview);
Drawable drawable = imageView.getDrawable();
Rect imageBounds = drawable.getBounds();
Run Code Online (Sandbox Code Playgroud)

然后使用Matrix.mapRect.

  • 所以,我的完整代码是`Rect bounds = imageView.getDrawable().getBounds(); RectF boundsF = new RectF(bounds); imageView.getImageMatrix().mapRect(boundsF); boundsF.round(bounds);` 谢谢,它奏效了,我终于修复了一个过渡! (2认同)