Android examples for User Interface:Touch Event
Is touch Event In View
//package com.java2s; import android.graphics.Rect; import android.view.MotionEvent; import android.view.View; public class Main { public static boolean touchEventInView(View view, MotionEvent ev) { int[] loc = new int[2]; Rect rect;/*from w ww .java 2 s .co m*/ view.getLocationInWindow(loc); rect = new Rect(0, 0, view.getWidth(), view.getHeight()); rect.offsetTo(loc[0], loc[1]); return rect.contains(round(ev.getRawX()), round(ev.getRawY())); } private static int round(float f) { return Math.round(f); } }