android 判断点击的位置是不是在指定的view上

private boolean inRangeOfView(View view, MotionEvent ev){
int[] location = new int[2];
view.getLocationOnScreen(location);
int x = location[0];
int y = location[1];
if(ev.getX() < x || ev.getX() > (x + view.getWidth()) || ev.getY() < y || ev.getY() > (y + view.getHeight())){
return false;
}
return true;
}
 
转载于:http://blog.sina.com.cn/s/blog_439f80c40101jud1.html
posted @ 2015-12-07 19:15  3H  阅读(7904)  评论(0编辑  收藏  举报