Example usage for android.widget RelativeLayout getLocationInWindow

List of usage examples for android.widget RelativeLayout getLocationInWindow

Introduction

In this page you can find the example usage for android.widget RelativeLayout getLocationInWindow.

Prototype

public void getLocationInWindow(@Size(2) int[] outLocation) 

Source Link

Document

Computes the coordinates of this view in its window.

Usage

From source file:Main.java

public static boolean isPointInsideOption(Point balloonLocation, RelativeLayout optionLayout) {
    int[] optionLocation = new int[2];

    optionLayout.getLocationInWindow(optionLocation);

    int x = balloonLocation.x;
    int y = balloonLocation.y;

    int oX = optionLocation[0];
    int oY = optionLocation[1];

    if (y >= oY && y <= oY + optionLayout.getHeight() && x >= oX && x <= oX + optionLayout.getWidth()) {

        return true;

    } else//from w  w w  . j a  v a 2s.  c om
        return false;
}