List of usage examples for android.view View getLeft
@ViewDebug.CapturedViewProperty public final int getLeft()
From source file:com.along.practice.widget.swipbacklayout.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * * @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. *//*w ww.j a v a 2s . c om*/ 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--) { // 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.support.v17.leanback.widget.GridWidgetTest.java
private static int getCenterX(View v) { return (v.getLeft() + v.getRight()) / 2; }
From source file:android.widget.Gallery.java
/** * Tracks a motion scroll. In reality, this is used to do just about any * movement to items (touch scroll, arrow-key scroll, set an item as selected). * //from ww w . j a v a 2 s .c om * @param deltaX Change in X from the previous event. */ void trackMotionScroll(int deltaX) { if (getChildCount() == 0) { return; } boolean toLeft = deltaX < 0; int limitedDeltaX = getLimitedMotionScrollAmount(toLeft, deltaX); if (limitedDeltaX != deltaX) { // The above call returned a limited amount, so stop any scrolls/flings mFlingRunnable.endFling(false); onFinishedMovement(); } offsetChildrenLeftAndRight(limitedDeltaX); detachOffScreenChildren(toLeft); if (toLeft) { // If moved left, there will be empty space on the right fillToGalleryRight(); } else { // Similarly, empty space on the left fillToGalleryLeft(); } // Clear unused views mRecycler.clear(); setSelectionToCenterChild(); final View selChild = mSelectedChild; if (selChild != null) { final int childLeft = selChild.getLeft(); final int childCenter = selChild.getWidth() / 2; final int galleryCenter = getWidth() / 2; mSelectedCenterOffset = childLeft + childCenter - galleryCenter; } onScrollChanged(0, 0, 0, 0); // dummy values, View's implementation does not use these. invalidate(); }
From source file:com.baidayi.swipback.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * /* w w w . ja v a 2 s. c om*/ * @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--) { // 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
/** * Tests scrollability within child views of v given a delta of dx. * /*from w ww.j a v a2s.com*/ * @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:com.zertinteractive.wallpaper.MainActivity.java
@SuppressWarnings("NewApi") private void animateRevealHide(final View viewRoot) { int cx = (viewRoot.getLeft() + viewRoot.getRight()) / 2; int cy = (viewRoot.getTop() + viewRoot.getBottom()) / 2; int initialRadius = viewRoot.getWidth(); android.animation.Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, cx, cy, initialRadius, 0);//from w w w . j a v a 2 s . co m anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(android.animation.Animator animation) { super.onAnimationEnd(animation); viewRoot.setVisibility(View.INVISIBLE); } }); anim.setDuration(getResources().getInteger(R.integer.anim_duration_medium)); anim.start(); }
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 ww w . java 2 s. c o m * * @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.//www.j ava 2s .c o m * * @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:aksha.upcomingdemo.HorizontalListView.java
/** Adds children views to the left and right of the current views until the screen is full */ private void fillList(final int dx) { // Get the rightmost child and determine its right edge int edge = 0; View child = getRightmostChild(); if (child != null) { edge = child.getRight();// w w w .j av a 2s .co m } // Add new children views to the right, until past the edge of the screen fillListRight(edge, dx); // Get the leftmost child and determine its left edge edge = 0; child = getLeftmostChild(); if (child != null) { edge = child.getLeft(); } // Add new children views to the left, until past the edge of the screen fillListLeft(edge, dx); }
From source file:android.widget.Gallery.java
/** * Obtain a view, either by pulling an existing view from the recycler or by * getting a new one from the adapter. If we are animating, make sure there * is enough information in the view's layout parameters to animate from the * old to new positions.//from w ww . j a va 2 s. c o m * * @param position Position in the gallery for the view to obtain * @param offset Offset from the selected position * @param x X-coordinate indicating where this view should be placed. This * will either be the left or right edge of the view, depending on * the fromLeft parameter * @param fromLeft Are we positioning views based on the left edge? (i.e., * building from left to right)? * @return A view that has been added to the gallery */ private View makeAndAddView(int position, int offset, int x, boolean fromLeft) { View child; if (!mDataChanged) { child = mRecycler.get(position); if (child != null) { // Can reuse an existing view int childLeft = child.getLeft(); // Remember left and right edges of where views have been placed mRightMost = Math.max(mRightMost, childLeft + child.getMeasuredWidth()); mLeftMost = Math.min(mLeftMost, childLeft); // Position the view setUpChild(child, offset, x, fromLeft); return child; } } // Nothing found in the recycler -- ask the adapter for a view child = mAdapter.getView(position, null, this); // Position the view setUpChild(child, offset, x, fromLeft); return child; }