ITeye博客

通过触摸事件判断当前是否触摸到某一个view

Mr.Cheney · 2015-08-24 11:35 · Android经验分享 · 移动开发 · Markdown

    public static boolean inTouchInslideOfView(View view, MotionEvent ev) {
        int[] location = new int[2];
        view.getLocationInWindow(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 true;
        }
        return false;
    }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。