List of usage examples for android.view View getScrollY
public final int getScrollY()
From source file:com.tjych.swip.vertical.DirectionalViewPager.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//w w w . ja v a 2 s . c o m * @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); }
From source file:com.minoon.stackviewpagersample.StackViewPager.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/* www . j ava 2 s . co m*/ * @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; // [Changed] // final int scrollX = v.getScrollX(); final int scrollX = (int) v.getTranslationX(); 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, -dx); }
From source file:com.example.mvpdemo.widget.NarrowParentViewPager.java
@Override public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) { Log.i(TAG, "onNestedPreScroll dx = " + dx + " dy = " + dy + " consumed = " + consumed[0] + "," + consumed[1]);// ww w.j av a2 s . co m int scrollY = target.getScrollY(); Log.i(TAG, "scrollY = " + scrollY); if (Math.abs(dy) > Math.abs(dx)) { if (dy < 0 && !ViewCompat.canScrollVertically(target, -1)) { childScrollUp(mDragDistance + dy); } else if (dy > 0) { boolean b = childScrollUp(mDragDistance + dy); if (b) { consumed[1] = dy; } } } super.onNestedPreScroll(target, dx, dy, consumed); }
From source file:cn.androidy.materialdesignsample.ryanharterviewpager.ViewPager.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/*from ww w. j a v a 2s.co m*/ * @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; } } } boolean canScroll = false; if (isOrientationHorizontal()) { canScroll = ViewCompat.canScrollHorizontally(v, -dx); } else { canScroll = ViewCompat.canScrollVertically(v, -dx); } return checkV && canScroll; }
From source file:com.viewpagerindicator.MyDirectionalViewPager.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 dposition 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. */// w ww .j a v a2s .co m protected boolean canScroll(View v, boolean checkV, int dposition, 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, dposition, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } if (mOrientation == HORIZONTAL) { return checkV && ViewCompat.canScrollHorizontally(v, -dposition); } else { return checkV && ViewCompat.canScrollVertically(v, -dposition); } }
From source file:com.guide.ViewPager.java
/** * Tests scrollability within child views of v given a delta of dx. * // w w w. j ava 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 * @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; } } } boolean canScroll = false; if (isOrientationHorizontal()) { canScroll = ViewCompat.canScrollHorizontally(v, -dx); } else { canScroll = ViewCompat.canScrollVertically(v, -dx); } return checkV && canScroll; }
From source file:android.improving.utils.views.cardsview.OrientedViewPager.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 delta 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. *///from w w w . ja va 2s.c o m protected boolean canScroll(View v, boolean checkV, int delta, 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 (mOrientation == Orientation.VERTICAL) { if (y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && canScroll(child, true, delta, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } else { if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, delta, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } } return checkV && ViewCompat.canScrollVertically(v, -delta); }
From source file:dev.dworks.libs.widget.ViewPager.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 d Delta scrolled in pixels//from w w w . j a v a 2s . c o m * @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 d, 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, d, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } boolean canScroll; if (mOrientation == HORIZONTAL) { canScroll = checkV && ViewCompat.canScrollHorizontally(v, -d); } else { canScroll = checkV && ViewCompat.canScrollVertically(v, -d); } return canScroll; }
From source file:org.bangbang.support.v4.widget.HListView.java
@Override public boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate) { int rectTopWithinChild = rect.top; // offset so rect is in coordinates of the this view rect.offset(child.getLeft(), child.getTop()); rect.offset(-child.getScrollX(), -child.getScrollY()); final int height = getHeight(); int listUnfadedTop = getScrollY(); int listUnfadedBottom = listUnfadedTop + height; final int fadingEdge = getVerticalFadingEdgeLength(); if (showingTopFadingEdge()) { // leave room for top fading edge as long as rect isn't at very top if ((mSelectedPosition > 0) || (rectTopWithinChild > fadingEdge)) { listUnfadedTop += fadingEdge; }//from www. j a va 2s . c o m } int childCount = getChildCount(); int bottomOfBottomChild = getChildAt(childCount - 1).getBottom(); if (showingBottomFadingEdge()) { // leave room for bottom fading edge as long as rect isn't at very bottom if ((mSelectedPosition < mItemCount - 1) || (rect.bottom < (bottomOfBottomChild - fadingEdge))) { listUnfadedBottom -= fadingEdge; } } int scrollYDelta = 0; if (rect.bottom > listUnfadedBottom && rect.top > listUnfadedTop) { // need to MOVE DOWN to get it in view: move down just enough so // that the entire rectangle is in view (or at least the first // screen size chunk). if (rect.height() > height) { // just enough to get screen size chunk on scrollYDelta += (rect.top - listUnfadedTop); } else { // get entire rect at bottom of screen scrollYDelta += (rect.bottom - listUnfadedBottom); } // make sure we aren't scrolling beyond the end of our children int distanceToBottom = bottomOfBottomChild - listUnfadedBottom; scrollYDelta = Math.min(scrollYDelta, distanceToBottom); } else if (rect.top < listUnfadedTop && rect.bottom < listUnfadedBottom) { // need to MOVE UP to get it in view: move up just enough so that // entire rectangle is in view (or at least the first screen // size chunk of it). if (rect.height() > height) { // screen size chunk scrollYDelta -= (listUnfadedBottom - rect.bottom); } else { // entire rect at top scrollYDelta -= (listUnfadedTop - rect.top); } // make sure we aren't scrolling any further than the top our children int top = getChildAt(0).getTop(); int deltaToTop = top - listUnfadedTop; scrollYDelta = Math.max(scrollYDelta, deltaToTop); } final boolean scroll = scrollYDelta != 0; if (scroll) { scrollListItemsBy(-scrollYDelta); positionSelector(child); mSelectedTop = child.getTop(); invalidate(); } return scroll; }
From source file:com.appunite.list.HorizontalListView.java
@Override public boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate) { int rectTopWithinChild = rect.top; // offset so rect is in coordinates of the this view rect.offset(child.getLeft(), child.getTop()); rect.offset(-child.getScrollX(), -child.getScrollY()); final int width = getWidth(); int listUnfadedLeft = getScrollX(); int listUnfadedRight = listUnfadedLeft + width; final int fadingEdge = getHorizontalFadingEdgeLength(); if (showingLeftFadingEdge()) { // leave room for top fading edge as long as rect isn't at very top if ((mSelectedPosition > 0) || (rectTopWithinChild > fadingEdge)) { listUnfadedLeft += fadingEdge; }/*from www . j a v a2 s.c om*/ } int childCount = getChildCount(); int rightOfRightChild = getChildAt(childCount - 1).getRight(); if (showingRightFadingEdge()) { // leave room for bottom fading edge as long as rect isn't at very bottom if ((mSelectedPosition < mItemCount - 1) || (rect.bottom < (rightOfRightChild - fadingEdge))) { listUnfadedRight -= fadingEdge; } } int scrollXDelta = 0; if (rect.right > listUnfadedRight && rect.left > listUnfadedLeft) { // need to MOVE DOWN to get it in view: move down just enough so // that the entire rectangle is in view (or at least the first // screen size chunk). if (rect.width() > width) { // just enough to get screen size chunk on scrollXDelta += (rect.left - listUnfadedLeft); } else { // get entire rect at bottom of screen scrollXDelta += (rect.right - listUnfadedRight); } // make sure we aren't scrolling beyond the end of our children int distanceToRight = rightOfRightChild - listUnfadedRight; scrollXDelta = Math.min(scrollXDelta, distanceToRight); } else if (rect.left < listUnfadedLeft && rect.right < listUnfadedRight) { // need to MOVE UP to get it in view: move up just enough so that // entire rectangle is in view (or at least the first screen // size chunk of it). if (rect.width() > width) { // screen size chunk scrollXDelta -= (listUnfadedRight - rect.right); } else { // entire rect at top scrollXDelta -= (listUnfadedLeft - rect.left); } // make sure we aren't scrolling any further than the top our children int left = getChildAt(0).getLeft(); int deltaToTop = left - listUnfadedLeft; scrollXDelta = Math.max(scrollXDelta, deltaToTop); } final boolean scroll = scrollXDelta != 0; if (scroll) { scrollListItemsBy(-scrollXDelta); positionSelector(INVALID_POSITION, child); mSelectedLeft = child.getLeft(); invalidate(); } return scroll; }