當前位置: 首頁>>代碼示例>>Java>>正文


Java View.getScrollX方法代碼示例

本文整理匯總了Java中android.view.View.getScrollX方法的典型用法代碼示例。如果您正苦於以下問題:Java View.getScrollX方法的具體用法?Java View.getScrollX怎麽用?Java View.getScrollX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.getScrollX方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: requestChildRectangleOnScreen

import android.view.View; //導入方法依賴的package包/類
public boolean requestChildRectangleOnScreen(RecyclerView parent, View child, Rect rect, boolean immediate) {
    int parentLeft = getPaddingLeft();
    int parentTop = getPaddingTop();
    int parentRight = getWidth() - getPaddingRight();
    int parentBottom = getHeight() - getPaddingBottom();
    int childLeft = (child.getLeft() + rect.left) - child.getScrollX();
    int childTop = (child.getTop() + rect.top) - child.getScrollY();
    int childRight = childLeft + rect.width();
    int childBottom = childTop + rect.height();
    int offScreenLeft = Math.min(0, childLeft - parentLeft);
    int offScreenTop = Math.min(0, childTop - parentTop);
    int offScreenRight = Math.max(0, childRight - parentRight);
    int offScreenBottom = Math.max(0, childBottom - parentBottom);
    int dx = getLayoutDirection() == 1 ? offScreenRight != 0 ? offScreenRight : Math.max(offScreenLeft, childRight - parentRight) : offScreenLeft != 0 ? offScreenLeft : Math.min(childLeft - parentLeft, offScreenRight);
    int dy = offScreenTop != 0 ? offScreenTop : Math.min(childTop - parentTop, offScreenBottom);
    if (dx == 0 && dy == 0) {
        return false;
    }
    if (immediate) {
        parent.scrollBy(dx, dy);
    } else {
        parent.smoothScrollBy(dx, dy);
    }
    return true;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:26,代碼來源:RecyclerView.java

示例2: canScroll

import android.view.View; //導入方法依賴的package包/類
/**
 * 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.
 */
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));
}
 
開發者ID:houshuai0816,項目名稱:DragVideos,代碼行數:36,代碼來源:CustomViewDragHelper.java

示例3: canScroll

import android.view.View; //導入方法依賴的package包/類
/**
 * 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
 * @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--)
        {
            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);
}
 
開發者ID:HueToYou,項目名稱:ChatExchange-old,代碼行數:36,代碼來源:CustomViewAbove.java

示例4: canScroll

import android.view.View; //導入方法依賴的package包/類
/**
 * 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
 * @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, -dx);
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:34,代碼來源:ViewPagerCompat.java

示例5: canScroll

import android.view.View; //導入方法依賴的package包/類
/**
 * 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
 * @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--) {
			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);
}
 
開發者ID:QuixomTech,項目名稱:WeatherStream,代碼行數:32,代碼來源:CustomViewAbove.java

示例6: canScroll

import android.view.View; //導入方法依賴的package包/類
/**
 * 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
 * @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--) {
      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);
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:31,代碼來源:SlidingUpPanelLayout.java

示例7: canScroll

import android.view.View; //導入方法依賴的package包/類
/**
 * 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.
 */
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));
}
 
開發者ID:Kaufland,項目名稱:andswipeframework,代碼行數:36,代碼來源:KDragViewHelper.java

示例8: canScroll

import android.view.View; //導入方法依賴的package包/類
/**
 * 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
 * @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--) {
            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);
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:32,代碼來源:CustomViewAbove.java

示例9: canScroll

import android.view.View; //導入方法依賴的package包/類
/**
 * 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
 * @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--) {
            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);
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:31,代碼來源:SlidingUpPanelLayout.java

示例10: canScroll

import android.view.View; //導入方法依賴的package包/類
/**
 * 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.
 */
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));
}
 
開發者ID:Zweihui,項目名稱:Aurora,代碼行數:36,代碼來源:SlideViewDragHelper.java

示例11: canScroll

import android.view.View; //導入方法依賴的package包/類
/**
 * 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.
 */
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));
}
 
開發者ID:wheat7,項目名稱:Cashew,代碼行數:40,代碼來源:ViewDragHelper.java

示例12: ScrollAnimation

import android.view.View; //導入方法依賴的package包/類
public ScrollAnimation(View view, int targetScrollX) {
	super();
	this.view = view;
	this.targetScrollX = targetScrollX;
	
	startScrollX = view.getScrollX();
	totalValue = this.targetScrollX - startScrollX;
	
	int time = Math.abs(totalValue);
	setDuration(time);
}
 
開發者ID:JackChan1999,項目名稱:SlidingMenu,代碼行數:12,代碼來源:ScrollAnimation.java

示例13: canScroll

import android.view.View; //導入方法依賴的package包/類
/**
 * 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
 * @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;
            }
        }
    }

    /* special case ViewPagers, which don't properly implement the scrolling interface */
    return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || !openable ||
            ((v instanceof ViewPager) && canViewPagerScrollHorizontally((ViewPager) v, -dx)));

    //return checkV && ViewCompat.canScrollHorizontally(v, (isLayoutRtlSupport() ? dx : -dx));
}
 
開發者ID:chemickypes,項目名稱:Glitchy,代碼行數:38,代碼來源:SideMenu.java

示例14: onTouch

import android.view.View; //導入方法依賴的package包/類
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    final int actionMasked = motionEvent.getActionMasked();
    if (actionMasked == MotionEvent.ACTION_DOWN) {
        if (view instanceof ViewGroup) {
            mInitialTouchTarget = findNearestChild((ViewGroup) view,
                    (int) motionEvent.getX(), (int) motionEvent.getY());
        } else {
            mInitialTouchTarget = null;
        }
    }

    final View child = mInitialTouchTarget;
    if (child == null) {
        return false;
    }

    final float offsetX = view.getScrollX() - child.getLeft();
    final float offsetY = view.getScrollY() - child.getTop();
    motionEvent.offsetLocation(offsetX, offsetY);
    final boolean handled = child.dispatchTouchEvent(motionEvent);
    motionEvent.offsetLocation(-offsetX, -offsetY);

    if (actionMasked == MotionEvent.ACTION_UP
            || actionMasked == MotionEvent.ACTION_CANCEL) {
        mInitialTouchTarget = null;
    }

    return handled;
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:31,代碼來源:TimePickerClockDelegate.java

示例15: handleClickableSpan

import android.view.View; //導入方法依賴的package包/類
public static boolean handleClickableSpan(View view, Layout layout, Spanned buffer, Class<? extends Clickable> spanType, MotionEvent event) {
  int action = event.getAction();

  if (action == MotionEvent.ACTION_UP ||
      action == MotionEvent.ACTION_DOWN) {
    int x = (int) event.getX();
    int y = (int) event.getY();

    x -= view.getPaddingLeft();
    y -= view.getPaddingTop();

    x += view.getScrollX();
    y += view.getScrollY();

    int line = layout.getLineForVertical(y);
    int off = layout.getOffsetForHorizontal(line, x);

    Clickable[] link = buffer.getSpans(off, off, spanType);

    if (link.length != 0) {
      if (action == MotionEvent.ACTION_UP) {
        link[0].onClick(view);
      } else if (buffer instanceof Spannable) {
        Selection.setSelection((Spannable) buffer,
            buffer.getSpanStart(link[0]),
            buffer.getSpanEnd(link[0]));
      }
      return true;
    } else if (buffer instanceof Spannable) {
      Selection.removeSelection((Spannable) buffer);
    }
  }

  return false;
}
 
開發者ID:lsjwzh,項目名稱:FastTextView,代碼行數:36,代碼來源:ClickableSpanUtil.java


注:本文中的android.view.View.getScrollX方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。