转载自:http://blog.youkuaiyun.com/nosxcy/article/details/7353310
private Rect mChangeImageBackgroundRect = null;
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
三星open source:http://opensource.samsung.com/
本文介绍了一种在Android中判断触摸事件坐标是否位于特定View内的方法。通过获取View的绘制区域并结合屏幕位置信息,可以精确地判断坐标点是否落在该View上。此方法对于实现触摸反馈或特殊交互效果非常有用。

1874

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



