Android View Check isPointInsideView(float x, float y, View view)

Here you can find the source of isPointInsideView(float x, float y, View view)

Description

Determines if given points are inside view

License

Open Source License

Parameter

Parameter Description
x - x coordinate of point
y - y coordinate of point
view - view object to compare

Return

true if the points are within view bounds, false otherwise

Declaration

public static boolean isPointInsideView(float x, float y, View view) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import android.view.View;

public class Main {
    /**/*from  ww  w .  j a v  a2 s  .  c o m*/
     * Determines if given points are inside view
     *
     * @param x    - x coordinate of point
     * @param y    - y coordinate of point
     * @param view - view object to compare
     * @return true if the points are within view bounds, false otherwise
     */
    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;
        }
    }
}

Related

  1. isAndroidOverScrollEnabled(View view)
  2. isImageView(View currentViewTocross)
  3. isRadioButtonView(View currentViewTocross)
  4. isScrollView(View v)
  5. isViewFromClass(Class type, View currentViewTocross)