简体   繁体   中英

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). 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 - eg 45 degrees?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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