List of usage examples for android.view View getLocationInWindow
public void getLocationInWindow(@Size(2) int[] outLocation)
Computes the coordinates of this view in its window.
From source file:Main.java
public static boolean pointInView(float x, float y, View v) { v.getLocationInWindow(mLocation); return x >= mLocation[0] && x < (mLocation[0] + v.getWidth()) && y >= mLocation[1] && y < (mLocation[1] + v.getHeight()); }
From source file:Main.java
/** * Helper for overriding {@link ViewGroup#gatherTransparentRegion} for views that are fully * opaque and have children extending beyond their bounds. If the transparent region * optimization is turned on (which is the case whenever the view hierarchy contains a * SurfaceView somewhere), the children might otherwise confuse the SurfaceFlinger. *//* w w w . j a v a2 s . c o m*/ public static void gatherTransparentRegionsForOpaqueView(View view, Region region) { view.getLocationInWindow(sLocationTmp); region.op(sLocationTmp[0], sLocationTmp[1], sLocationTmp[0] + view.getRight() - view.getLeft(), sLocationTmp[1] + view.getBottom() - view.getTop(), Region.Op.DIFFERENCE); }
From source file:Main.java
public static int[] getLocationInWindow(View view) { int[] location = new int[2]; view.getLocationInWindow(location); return location; }
From source file:Main.java
public static int getLocationInYAxis(View v) { final int[] globalPos = new int[2]; v.getLocationInWindow(globalPos); return globalPos[1]; }
From source file:Main.java
public static int getLocationInXAxis(View v) { final int[] globalPos = new int[2]; v.getLocationInWindow(globalPos); return globalPos[0]; }
From source file:Main.java
public static boolean isEventInView(MotionEvent ev, View view) { int[] location = new int[2]; view.getLocationInWindow(location); if (ev.getX() > location[0] && ev.getX() < location[0] + view.getWidth() && ev.getY() > location[1] && ev.getY() < location[1] + view.getHeight()) { return true; }/*from ww w .j a v a 2 s .c o m*/ return false; }
From source file:Main.java
public static int[] getViewItemLocation(View view) { int[] location = new int[2]; //each item location view.getLocationInWindow(location); return location; }
From source file:Main.java
public static int[] getCenterDeltaInScreenSpace(View v0, View v1, int[] delta) { v0.getLocationInWindow(sLoc0); v1.getLocationInWindow(sLoc1);/*from w w w .j a va 2 s .c o m*/ sLoc0[0] += (v0.getMeasuredWidth() * v0.getScaleX()) / 2; sLoc0[1] += (v0.getMeasuredHeight() * v0.getScaleY()) / 2; sLoc1[0] += (v1.getMeasuredWidth() * v1.getScaleX()) / 2; sLoc1[1] += (v1.getMeasuredHeight() * v1.getScaleY()) / 2; if (delta == null) { delta = new int[2]; } delta[0] = sLoc1[0] - sLoc0[0]; delta[1] = sLoc1[1] - sLoc0[1]; return delta; }
From source file:Main.java
public static RectF calculeRectInWindow(View view) { int[] location = new int[2]; view.getLocationInWindow(location); return new RectF(location[0], location[1], location[0] + view.getMeasuredWidth(), location[1] + view.getMeasuredHeight()); }
From source file:Main.java
static Rect getViewAbsRect(View view, int parentX, int parentY) { int[] loc = new int[2]; view.getLocationInWindow(loc); Rect rect = new Rect(); rect.set(loc[0], loc[1], loc[0] + view.getMeasuredWidth(), loc[1] + view.getMeasuredHeight()); rect.offset(-parentX, -parentY);// ww w. j a va2 s. co m return rect; }