码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2015-12-07 20:48:25      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:

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

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

标签:

原文地址:http://www.cnblogs.com/shortboy/p/5027158.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!