I found that Sebastian Roth answered very helpful with resources, but since that was not my answer, I thought I would share what I came up with.
Here is the code that I use to detect views (only those that will accept drops) with a coordinate on the screen.
private DropView findDropTarget( int x, int y, int[] dropCoordinates ){
final Rect r = mRectTemp;
final ArrayList<DropView> dropTargets = ((main) context).getBoardDropTargets();
final int count = dropTargets.size();
for (int i=count-1; i>=0; i--) {
final DropView target = dropTargets.get(i);
target.getHitRect(r);
target.getLocationOnScreen(dropCoordinates);
r.offset(dropCoordinates[0] - target.getLeft(), dropCoordinates[1] - target.getTop());
if (r.contains(x, y)) {
dropCoordinates[0] = x - dropCoordinates[0];
dropCoordinates[1] = y - dropCoordinates[1];
return target;
}
}
}
Ok, first mRectTemp is just the highlighted Rectangle, so you don't need to create new ones (IE final Rect r = new Rect ())
The next line of dropTargets is a list of views that will accept a drop in my application. Then I look at each view.
Then I use getHitRect (r) to return the coordinates of the view screen.
Then I compensate the coordinates to account for the notification bar or any other view that could shift the coordinates.
, , x y r (x y - event.rawX() event.rawY()).
, , .