Android examples for User Interface:View Click
View hit Test
//package com.java2s; import android.support.v4.view.ViewCompat; import android.view.View; public class Main { public static boolean hitTest(View v, int x, int y) { final int tx = (int) (ViewCompat.getTranslationX(v) + 0.5f); final int ty = (int) (ViewCompat.getTranslationY(v) + 0.5f); final int left = v.getLeft() + tx; final int right = v.getRight() + tx; final int top = v.getTop() + ty; final int bottom = v.getBottom() + ty; return (x >= left) && (x <= right) && (y >= top) && (y <= bottom); }/*from w w w . java2 s . c o m*/ }