---
title: "通过触摸事件判断当前是否触摸到某一个view"
author: "Mr.Cheney"
date: "2015-08-24T11:35:01Z"
tags: []
categories: ["移动开发"]
slug: "view"
draft: false
lastmod: "2015-08-24T11:35:01Z"
id: 2237560
url: "https://mr-cheney.iteye.com/blog/2237560"
---

```
    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;
    }
```