简体   繁体   English

Android:我的imageview旋转了,但是它的触摸区域没有

[英]Android: My imageview is rotated, but its touch area isn't

I have a rectangular Imageview that responds to touch (it rotates by a specific number of degrees, using animation). 我有一个矩形的Imageview,可以响应触摸(使用动画它旋转特定的角度)。 The imageview has an ontouchlistener attached to it. imageview带有附加的ontouchlistener。

However, once it has rotated, it still responds to touch only at its original (pre-rotation) location. 但是,一旦旋转,它仍然仅在其原始(预旋转)位置响应触摸。 Even though I have setfillafter to true. 即使我将setfillafter设置为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 - eg 45 degrees? 我的理论是旋转仅用于显示目的...有没有办法检测以45度角旋转的矩形图像视图上的触摸?

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. 当将动画应用于android中的视图时,只有视图的像素移动,而命中区域保持在相同位置。

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. 要实际移动视图,您需要向该视图添加动画侦听器,并手动更改动画末端的视图位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM