Android examples for User Interface:View Contains
Returns true if the point is within the view's bounds.
//package com.java2s; import android.view.View; public class Main { /**// w ww. jav a 2 s . c o m * Returns true if the point is within the view's bounds. * @param x * @param y * @param view * @return */ public static boolean isPointInsideView(float x, float y, View view) { int location[] = new int[2]; view.getLocationOnScreen(location); int viewX = location[0]; int viewY = location[1]; //point is inside view bounds if ((x > viewX && x < (viewX + view.getWidth())) && (y > viewY && y < (viewY + view.getHeight()))) { return true; } else { return false; } } }