如何检查拖动视图的位置是否覆盖另一个视图
How to check position of dragging view is lying over the another view or not
I have these round dragable buttons i am using set setTranslationX()
setTranslationY() inside the ontouch event for drag functionality.
How i can get to know that if any button dragged to middle of the icon, is lying over the middle icon or not?
谢谢@Dheerubhai Bansal 最后我完成了使用这种碰撞方法。可以很好地找到两个视图之间的交集
public boolean CheckCollision(View v1, View v2) {
Rect myViewRect = new Rect();
v1.getHitRect(myViewRect);
Rect otherViewRect1 = new Rect();
v2.getHitRect(otherViewRect1);
return Rect.intersects(myViewRect, otherViewRect1);
}
I have these round dragable buttons i am using set setTranslationX() setTranslationY() inside the ontouch event for drag functionality. How i can get to know that if any button dragged to middle of the icon, is lying over the middle icon or not?
谢谢@Dheerubhai Bansal 最后我完成了使用这种碰撞方法。可以很好地找到两个视图之间的交集
public boolean CheckCollision(View v1, View v2) {
Rect myViewRect = new Rect();
v1.getHitRect(myViewRect);
Rect otherViewRect1 = new Rect();
v2.getHitRect(otherViewRect1);
return Rect.intersects(myViewRect, otherViewRect1);
}