List of usage examples for android.view View getLocationOnScreen
public void getLocationOnScreen(@Size(2) int[] outLocation)
Computes the coordinates of this view on the screen.
From source file:Main.java
public static int[] getLocationOnScreen(View v) { int[] location = new int[2]; v.getLocationOnScreen(location); return location; }
From source file:Main.java
private static int[] getCenterOf(View view) { int[] loc = new int[2]; view.getLocationOnScreen(loc); loc[0] += (view.getWidth() / 2); //middle of button loc[1] += (view.getHeight() / 2); //middle of button return loc;//from w w w. ja v a2 s.c o m }
From source file:Main.java
public static int[] getViewLocation(View view) { int[] location = new int[2]; view.getLocationOnScreen(location); return location; }
From source file:Main.java
public static int[] getLocationOnScreen(View view) { int[] location = new int[2]; view.getLocationOnScreen(location); return location; }
From source file:Main.java
public static int[] getViewLocation(View view) { int[] loc = new int[] { 0, 0 }; view.getLocationOnScreen(loc); loc[0] = (loc[0] + view.getWidth()); loc[1] = (loc[1] + view.getHeight()); return loc;/*from w ww . j av a 2 s . c o m*/ }
From source file:Main.java
public static int[] getViewCenterLocation(View view) { int[] loc = new int[] { 0, 0 }; view.getLocationOnScreen(loc); loc[0] = (loc[0] + view.getWidth() / 2); loc[1] = (loc[1] + view.getHeight() / 2); return loc;/* www .ja v a2 s . c o m*/ }
From source file:Main.java
public static boolean isTouchInView(MotionEvent ev, View v) { int[] vLoc = new int[2]; v.getLocationOnScreen(vLoc); float motionX = ev.getRawX(); float motionY = ev.getRawY(); return motionX >= vLoc[0] && motionX <= (vLoc[0] + v.getWidth()) && motionY >= vLoc[1] && motionY <= (vLoc[1] + v.getHeight()); }
From source file:Main.java
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 {// w w w. j a v a2s . c om return false; } }
From source file:Main.java
/** * <pre>// w w w . ja v a 2 s .c o m * Determine whether a {@link MotionEvent} is on a {@link View} * </pre> */ public static boolean motionEventOnView(MotionEvent event, View view) { int[] location = new int[2]; view.getLocationOnScreen(location); int x = location[0]; int y = location[1]; int w = view.getWidth(); int h = view.getHeight(); Rect rect = new Rect(x, y, x + w, y + h); return rect.contains((int) event.getRawX(), (int) event.getRawY()); }
From source file:Main.java
public static int[] viewCoordinates(View view) { int[] viewLocation = new int[2]; view.getLocationOnScreen(viewLocation); return viewLocation; }