点击区域,是否在某个view内
作者:
皓皓amous | 来源:发表于
2022-06-16 15:53 被阅读0次private boolean isWithinViewRange(View view, int x, int y) {
if (null == isWithinViewRangerRect) {
isWithinViewRangerRect = new Rect();
}
view.getDrawingRect(isWithinViewRangerRect);
int[] location = new int[2];
view.getLocationOnScreen(location);
isWithinViewRangerRect.left = location[0];
isWithinViewRangerRect.top = location[1];
isWithinViewRangerRect.bottom = isWithinViewRangerRect.bottom + location[1];
isWithinViewRangerRect.right = isWithinViewRangerRect.right + location[0];
return isWithinViewRangerRect.contains(x, y);
}
本文标题:点击区域,是否在某个view内
本文链接:https://www.haomeiwen.com/subject/zvjqvrtx.html
网友评论