Android:我的图像视图已旋转,但其触摸区域未旋转
我有一个响应触摸的矩形 Imageview(它使用动画旋转特定的度数)。 imageview 附加了一个 ontouchlistener。
然而,一旦旋转,它仍然仅在其原始(旋转前)位置响应触摸。即使我已将 fillafter 设置为 true。
我的理论是,旋转仅用于显示目的...有没有办法检测以一定角度(例如 45 度)旋转的矩形图像视图上的触摸?
I have a rectangular Imageview that responds to touch (it rotates by a specific number of degrees, using animation). The imageview has an ontouchlistener attached to it.
However, once it has rotated, it still responds to touch only at its original (pre-rotation) location. Even though I have setfillafter to true.
My theory is that the rotation is for display purposes only... is there a way to detect a touch on a rectangular imageview rotated at an angle - e.g. 45 degrees?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当动画应用于 Android 中的视图时,仅视图的像素发生移动,而点击区域保持在相同位置。
要实际移动视图,您需要向视图添加动画侦听器,并在动画结束时手动更改视图位置。
When animation is applied to a view in android, only the pixels of the view are shifted while the hit area remains in the same position.
To actually move a view, you will need to add a animation listener to the view and manually change the view position on animation end.