Android:缩放 ImageView 及其 onDraw() 项目
所有,我扩展了 ImageView 以便在图像上实现捏合和缩放缩放。这是通过修改矩阵并将其应用于图像来完成的。现在,我还重写 onDraw() 来绘制图元(即矩形和圆形)。我已将矩阵应用到画布上,它似乎已正确处理缩放,但唯一的问题是该位置在绘制的项目上关闭。我该如何翻译绘制项目的位置以反映新的比例?
All, I've extended the ImageView in order to implement pinch and zoom scaling on the image. This is done by modifying the matrix and applying it to the image. Now, I am also overwriting the onDraw() to draw primitives (i.e. rectangles and circles). I've applied the matrix to the canvas and it appears to have handled the scaling properly, but the only problem is that that position is off on the drawn items. How do I go about translating the positions of the drawn items to reflect the new scale?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一种不用矩阵的方法,可以直接在onDraw方法中实现捏合和缩放。查看此博客文章:http://android-developers。 blogspot.com/2010/06/making-sense-of-multitouch.html
There is an aproach without matrix, you can implement the pinch and zoom directly in the onDraw method. Check this blog post: http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html