List of usage examples for android.view View getRight
@ViewDebug.CapturedViewProperty public final int getRight()
From source file:android.improving.utils.views.swipeback.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * /*from ww w . j a v a 2 s . c o m*/ * @param v * View to test for horizontal scrollability * @param checkV * Whether the view v passed should itself be checked for * scrollability (true), or just its children (false). * @param dx * Delta scrolled in pixels along the X axis * @param dy * Delta scrolled in pixels along the Y axis * @param x * X coordinate of the active touch point * @param y * Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance // first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy)); }
From source file:android.improving.utils.views.swipeback.ViewDragHelper.java
/** * Find the topmost child under the given point within the parent view's * coordinate system. The child order is determined using * {@link com.way.ui.swipeback.ViewDragHelper.Callback#getOrderedChildIndex(int)} * .//from w ww. j a va 2 s. c om * * @param x * X position to test in the parent's coordinate system * @param y * Y position to test in the parent's coordinate system * @return The topmost child view under (x, y) or null if none found. */ public View findTopChildUnder(int x, int y) { final int childCount = mParentView.getChildCount(); for (int i = childCount - 1; i >= 0; i--) { final View child = mParentView.getChildAt(mCallback.getOrderedChildIndex(i)); if (x >= child.getLeft() && x < child.getRight() && y >= child.getTop() && y < child.getBottom()) { return child; } } return null; }
From source file:android.improving.utils.views.swipeback.ViewDragHelper.java
/** * Determine if the supplied view is under the given point in the parent * view's coordinate system./* w w w . j a v a 2 s .com*/ * * @param view * Child view of the parent to hit test * @param x * X position to test in the parent's coordinate system * @param y * Y position to test in the parent's coordinate system * @return true if the supplied view is under the given point, false * otherwise */ public boolean isViewUnder(View view, int x, int y) { if (view == null) { return false; } return x >= view.getLeft() && x < view.getRight() && y >= view.getTop() && y < view.getBottom(); }
From source file:android.widget.Gallery.java
private void fillToGalleryRightRtl() { int itemSpacing = mSpacing; int galleryRight = mRight - mLeft - mPaddingRight; // Set state for initial iteration View prevIterationView = getChildAt(0); int curPosition; int curLeftEdge; if (prevIterationView != null) { curPosition = mFirstPosition - 1; curLeftEdge = prevIterationView.getRight() + itemSpacing; } else {//from www .ja v a2 s. c o m curPosition = 0; curLeftEdge = mPaddingLeft; mShouldStopFling = true; } while (curLeftEdge < galleryRight && curPosition >= 0) { prevIterationView = makeAndAddView(curPosition, curPosition - mSelectedPosition, curLeftEdge, true); // Remember some state mFirstPosition = curPosition; // Set state for next iteration curLeftEdge = prevIterationView.getRight() + itemSpacing; curPosition--; } }
From source file:com.aviary.android.feather.sdk.widget.AviaryWorkspace.java
private void fillToGalleryRight() { int itemSpacing = 0; int galleryRight = getScreenScrollPositionX(mCurrentScreen + 2); int numChildren = getChildCount(); int numItems = mItemCount; // Set state for initial iteration View prevIterationView = getChildAt(numChildren - 1); int curPosition; int curLeftEdge; if (prevIterationView != null) { curPosition = mFirstPosition + numChildren; curLeftEdge = prevIterationView.getRight() + itemSpacing; } else {/* w w w. java 2s .c o m*/ mFirstPosition = curPosition = mItemCount - 1; curLeftEdge = mPaddingLeft; } while (curLeftEdge < galleryRight && curPosition < numItems) { prevIterationView = makeAndAddView(curPosition, curPosition - mCurrentScreen, curLeftEdge, true); // Set state for next iteration curLeftEdge = prevIterationView.getRight() + itemSpacing; curPosition++; } }
From source file:android.widget.Gallery.java
private void fillToGalleryRightLtr() { int itemSpacing = mSpacing; int galleryRight = mRight - mLeft - mPaddingRight; int numChildren = getChildCount(); int numItems = mItemCount; // Set state for initial iteration View prevIterationView = getChildAt(numChildren - 1); int curPosition; int curLeftEdge; if (prevIterationView != null) { curPosition = mFirstPosition + numChildren; curLeftEdge = prevIterationView.getRight() + itemSpacing; } else {//from ww w. j a va 2s .c o m mFirstPosition = curPosition = mItemCount - 1; curLeftEdge = mPaddingLeft; mShouldStopFling = true; } while (curLeftEdge < galleryRight && curPosition < numItems) { prevIterationView = makeAndAddView(curPosition, curPosition - mSelectedPosition, curLeftEdge, true); // Set state for next iteration curLeftEdge = prevIterationView.getRight() + itemSpacing; curPosition++; } }
From source file:cn.zmdx.kaka.locker.widget.SlidingPaneLayout.java
/** * Tests scrollability within child views of v given a delta of dx. * /* w w w .ja v a 2s. co m*/ * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for * scrollability (true), or just its children (false). * @param dx Delta scrolled in pixels * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance // first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollHorizontally(v, (isLayoutRtlSupport() ? dx : -dx)); }
From source file:com.android.dialer.widget.OverlappingPaneLayout.java
void updateObscuredViewsVisibility(View panel) { final int startBound = getPaddingTop(); final int endBound = getHeight() - getPaddingBottom(); final int leftBound = getPaddingLeft(); final int rightBound = getWidth() - getPaddingRight(); final int left; final int right; final int top; final int bottom; if (panel != null && viewIsOpaque(panel)) { left = panel.getLeft();/*from ww w .ja va 2 s . com*/ right = panel.getRight(); top = panel.getTop(); bottom = panel.getBottom(); } else { left = right = top = bottom = 0; } for (int i = 0, childCount = getChildCount(); i < childCount; i++) { final View child = getChildAt(i); if (child == panel) { // There are still more children above the panel but they won't be affected. break; } final int clampedChildLeft = Math.max(leftBound, child.getLeft()); final int clampedChildRight = Math.min(rightBound, child.getRight()); final int clampedChildTop = Math.max(startBound, child.getTop()); final int clampedChildBottom = Math.min(endBound, child.getBottom()); final int vis; if (clampedChildLeft >= left && clampedChildTop >= top && clampedChildRight <= right && clampedChildBottom <= bottom) { vis = INVISIBLE; } else { vis = VISIBLE; } child.setVisibility(vis); } }
From source file:com.jzh.stuapp.view.MyViewPager.java
/** * Tests scrollability within child views of v given a delta of dx. * // w w w . j a v a2 s . c o m * @param v * View to test for horizontal scrollability * @param checkV * Whether the view v passed should itself be checked for * scrollability (true), or just its children (false). * @param dx * Delta scrolled in pixels * @param x * X coordinate of the active touch point * @param y * Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); for (int i = count - 1; i >= 0; i--) { final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollHorizontally(v, -dx); }
From source file:com.android.calculator2.Calculator.java
private void reveal(View sourceView, int colorRes, AnimatorListener listener) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay(); final Rect displayRect = new Rect(); mDisplayView.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(this); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(getResources().getColor(colorRes)); groupOverlay.add(revealView);//from w w w .j a va 2 s . co m final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime)); revealAnimator.addListener(listener); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); mCurrentAnimator = null; } }); mCurrentAnimator = animatorSet; animatorSet.start(); }