use*_*425 5 android ontouchlistener android-image android-imageview android-gesture
在我的应用程序中,我使用的是在屏幕上移动图像onTouchListener.
我在同一视图中有另外两张图像.我的问题是,当运动图像触摸任何其他图像时,我需要执行某个动作(这意味着如果图像相交,则执行某些操作).
怎么能实现呢?.请尽快帮助我
提前致谢.
ter*_*er0 14
您应该能够使用Rect.intersects(Rect, Rect),如下例所示:
Rect myViewRect = new Rect();
myView.getHitRect(myViewRect);
Rect otherViewRect1 = new Rect();
otherView1.getHitRect(otherViewRect1);
Rect otherViewRect2 = new Rect();
otherView2.getHitRect(otherViewRect2);
if (Rect.intersects(myViewRect, otherViewRect1)) {
// Intersects otherView1
}
if (Rect.intersects(myViewRect, otherViewRect2)) {
// Intersects otherView2
}
Run Code Online (Sandbox Code Playgroud)
参考在这里.
| 归档时间: |
|
| 查看次数: |
4446 次 |
| 最近记录: |