private Rect mChangeImageBackgroundRect = null;
mChangeImageBackgroundRect = new Rect();
}
view.getDrawingRect(mChangeImageBackgroundRect);
int[] location = new int[2];
view.getLocationOnScreen(location);
mChangeImageBackgroundRect.left = location[0];
mChangeImageBackgroundRect.top = location[1];
mChangeImageBackgroundRect.right = mChangeImageBackgroundRect.right + location[0];
mChangeImageBackgroundRect.bottom = mChangeImageBackgroundRect.bottom + location[1];
return mChangeImageBackgroundRect.contains(x, y);
private boolean isInChangeImageZone(View view, int x, int y) {
if (null == mChangeImageBackgroundRect) {mChangeImageBackgroundRect = new Rect();
}
view.getDrawingRect(mChangeImageBackgroundRect);
int[] location = new int[2];
view.getLocationOnScreen(location);
mChangeImageBackgroundRect.left = location[0];
mChangeImageBackgroundRect.top = location[1];
mChangeImageBackgroundRect.right = mChangeImageBackgroundRect.right + location[0];
mChangeImageBackgroundRect.bottom = mChangeImageBackgroundRect.bottom + location[1];
return mChangeImageBackgroundRect.contains(x, y);
}
其中view是要判断的view ,x,y是Down X, Down Y
本文介绍了一段代码实现的功能:通过给定的视图和坐标点,判断该点是否位于视图中定义的改变图像背景区域内部。涉及到获取视图的绘制矩形、计算视图的位置并调整矩形边界,最后使用矩形包含点的方法进行判断。
1873

被折叠的 条评论
为什么被折叠?



