然后尝试检测这两个图像视图的冲突,我尝试了3种在stackoverflow上找到的方法。
喜欢这些:
public boolean CheckCollision(View v1,View v2) { Rect R1=new Rect(v1.getLeft(), v1.getTop(), v1.getRight(), v1.getBottom()); Rect R2=new Rect(v2.getLeft(), v2.getTop(), v2.getRight(), v2.getBottom()); return R1.intersect(R2); } public boolean chk(ImageView v1,ImageView v2) { Rect R1=new Rect(); v1.getDrawingRect(R1); Rect R2=new Rect(); v2.getDrawingRect(R2); return Rect.intersects(R1,R2); } public boolean chkm(ImageView v1,ImageView v2) { Rect R1=new Rect(); v1.getHitRect(R1); Rect R2=new Rect(); v2.getHitRect(R2); return R1.intersect(R2); }
[无论我尝试哪种方法,在应用程序启动时,拖动过程中或拖动之后,它们总是会给我'true',而我可以正确地检测每个imageview的坐标而没有问题。
[如果有人可以帮助我纠正我可能犯的愚蠢错误,将不胜感激>。<
谢谢!
正如该主题中简要说明的那样,我正在尝试检测我在一个显示在所有内容之上的应用程序中显示的2个图像视图的冲突,这是一个浮动窗口小部件服务。我的第一个图像视图是p:p ...