Is point In View - Android android.view

Android examples for android.view:View

Description

Is point In View

Demo Code

import android.view.View;

public class Main {

  private static int sLocation[] = new int[2];

  public static boolean pointInView(float x, float y, View v) {
    v.getLocationInWindow(sLocation);/*  ww  w . j  a  v  a2  s. co m*/
    return x >= sLocation[0] && x < (sLocation[0] + v.getWidth()) && y >= sLocation[1]
        && y < (sLocation[1] + v.getHeight());
  }

}

Related Tutorials