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:com.atwal.wakeup.battery.util.Utilities.java
/** * ???target View // ww w .j ava 2 s . com * * @param view * @param ev * @return */ public static boolean inRangeOfView(View view, MotionEvent ev) { int[] location = new int[2]; view.getLocationOnScreen(location); int x = location[0]; int y = location[1]; if (ev.getX() < x || ev.getX() > (x + view.getWidth()) || ev.getY() < y || ev.getY() > (y + view.getHeight())) { return false; } return true; }
From source file:io.selendroid.server.model.internal.execute_native.IsElementDisplayedInViewport.java
@SuppressWarnings("deprecation") public boolean isDisplayedOnViewport(View view) { int coordinates[] = { -1, -1 }; int width = 0, height = 0; view.getLocationOnScreen(coordinates); if (coordinates[0] + view.getWidth() < 0) return false; if (coordinates[1] + view.getHeight() < 0) return false; if (width == 0 || height == 0) { if (instrumentation.getContext() == null) return false; Display display = ((WindowManager) instrumentation.getContext() .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); try {/*from ww w. j a v a 2s .c o m*/ android.graphics.Point screenSize = new android.graphics.Point(); display.getSize(screenSize); width = screenSize.x; height = screenSize.y; } catch (NoSuchMethodError e) { width = display.getWidth(); height = display.getHeight(); } } if (coordinates[0] > width) return false; if (coordinates[1] > height) return false; return true; }
From source file:com.zandbee.floatingtitlebar.FloatingTitleBarActivity.java
/** @return the view's location taking the status bar into account */ private int getLocationYonScreen(View view) { view.getLocationOnScreen(location); return location[1] - statusBarHeight; }
From source file:com.jaspervanriet.huntingthatproduct.Views.FeedContextMenuManager.java
private void setupContextMenuInitialPosition(View openingView) { final int[] openingViewLocation = new int[2]; openingView.getLocationOnScreen(openingViewLocation); int additionalBottomMargin = Utils.dpToPx(16); contextMenuView.setTranslationX(openingViewLocation[0] - contextMenuView.getWidth() / 3); contextMenuView/* w w w. j a va 2 s .c o m*/ .setTranslationY(openingViewLocation[1] - contextMenuView.getHeight() - additionalBottomMargin); }
From source file:com.android.cts.uiautomator.TestGenericDetailFragment.java
/** * Collects pointer touch information converting from relative to absolute before * storing it as starting touch coordinates. * * @param event/*w w w . ja v a2 s .com*/ * @param view * @param pointerIndex */ private void collectStartAction(MotionEvent event, View view, int pointerIndex) { int offsetInScreen[] = new int[2]; view.getLocationOnScreen(offsetInScreen); mPointerEvents[getPointerId(event)].startX = (int) (event.getX(pointerIndex) + offsetInScreen[0]); mPointerEvents[getPointerId(event)].startY = (int) (event.getY(pointerIndex) + offsetInScreen[1]); }
From source file:com.android.cts.uiautomator.TestGenericDetailFragment.java
/** * Collects pointer touch information converting from relative to absolute before * storing it as ending touch coordinates. * * @param event// w w w .j a va 2 s.co m * @param view * @param pointerIndex */ private void collectEndAction(MotionEvent event, View view, int pointerIndex) { int offsetInScreen[] = new int[2]; view.getLocationOnScreen(offsetInScreen); mPointerEvents[getPointerId(event)].endX = (int) (event.getX(pointerIndex) + offsetInScreen[0]); mPointerEvents[getPointerId(event)].endY = (int) (event.getY(pointerIndex) + offsetInScreen[1]); }
From source file:android.support.transition.Slide.java
private void captureValues(TransitionValues transitionValues) { View view = transitionValues.view; int[] position = new int[2]; view.getLocationOnScreen(position); transitionValues.values.put(PROPNAME_SCREEN_POSITION, position); }
From source file:app.hanks.com.conquer.activity.MainActivity.java
public void launcherAddTaskActivity(View v) { int[] startingLocation = new int[2]; v.getLocationOnScreen(startingLocation); startingLocation[0] += v.getWidth() / 2; AddTaskActivity.startUserProfileFromLocation(startingLocation, this); overridePendingTransition(0, 0);//from w w w .ja v a 2s. com }
From source file:android.support.v7.widget.ForwardingListener.java
/** * Emulates View.toLocalMotionEvent(). This implementation does not handle transformations * (scaleX, scaleY, etc).//www .j a v a 2 s. com */ private boolean toLocalMotionEvent(View view, MotionEvent event) { final int[] loc = mTmpLocation; view.getLocationOnScreen(loc); event.offsetLocation(-loc[0], -loc[1]); return true; }
From source file:android.support.v7.widget.ForwardingListener.java
/** * Emulates View.toGlobalMotionEvent(). This implementation does not handle transformations * (scaleX, scaleY, etc).//from w w w. j av a2 s . com */ private boolean toGlobalMotionEvent(View view, MotionEvent event) { final int[] loc = mTmpLocation; view.getLocationOnScreen(loc); event.offsetLocation(loc[0], loc[1]); return true; }