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


Java ViewCompat.canScrollHorizontally方法代碼示例

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


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

示例1: canScroll

import android.support.v4.view.ViewCompat; //導入方法依賴的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

示例2: canScroll

import android.support.v4.view.ViewCompat; //導入方法依賴的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:Vinetos,項目名稱:Hello-Music-droid,代碼行數:36,代碼來源:ViewDragHelper.java

示例3: canScroll

import android.support.v4.view.ViewCompat; //導入方法依賴的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:Jusenr,項目名稱:RX_Demo,代碼行數:34,代碼來源:ResideLayout.java

示例4: canScroll

import android.support.v4.view.ViewCompat; //導入方法依賴的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:sega4revenge,項目名稱:Sega,代碼行數:34,代碼來源:ViewPagerEx.java

示例5: canScroll

import android.support.v4.view.ViewCompat; //導入方法依賴的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:eventtus,項目名稱:photo-editor-android,代碼行數:31,代碼來源:SlidingUpPanelLayout.java

示例6: canScroll

import android.support.v4.view.ViewCompat; //導入方法依賴的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:6ag,項目名稱:LiuAGeAndroid,代碼行數:32,代碼來源:CustomViewAbove.java

示例7: canScroll

import android.support.v4.view.ViewCompat; //導入方法依賴的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:eventtus,項目名稱:photo-editor-android,代碼行數:36,代碼來源:ViewDragHelper.java

示例8: canScroll

import android.support.v4.view.ViewCompat; //導入方法依賴的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;
			}
		}
	}
	// Modified by shihao. ViewCompat.canScrollHorizontally is not working
	// for version lower than ICE_CREAM_SANDWICH so here we must do ugly
	// hacking.
	return checkV && ViewCompat.canScrollHorizontally(v, dx);
}
 
開發者ID:fengshihao,項目名稱:WebPager,代碼行數:44,代碼來源:CustomViewPager.java

示例9: performAccessibilityAction

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public boolean performAccessibilityAction(Recycler recycler, State state, int action, Bundle args) {
    if (this.mRecyclerView == null) {
        return false;
    }
    int vScroll = 0;
    int hScroll = 0;
    switch (action) {
        case 4096:
            if (ViewCompat.canScrollVertically(this.mRecyclerView, 1)) {
                vScroll = (getHeight() - getPaddingTop()) - getPaddingBottom();
            }
            if (ViewCompat.canScrollHorizontally(this.mRecyclerView, 1)) {
                hScroll = (getWidth() - getPaddingLeft()) - getPaddingRight();
                break;
            }
            break;
        case 8192:
            if (ViewCompat.canScrollVertically(this.mRecyclerView, -1)) {
                vScroll = -((getHeight() - getPaddingTop()) - getPaddingBottom());
            }
            if (ViewCompat.canScrollHorizontally(this.mRecyclerView, -1)) {
                hScroll = -((getWidth() - getPaddingLeft()) - getPaddingRight());
                break;
            }
            break;
    }
    if (vScroll == 0 && hScroll == 0) {
        return false;
    }
    this.mRecyclerView.scrollBy(hScroll, vScroll);
    return true;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:33,代碼來源:RecyclerView.java

示例10: onInitializeAccessibilityNodeInfo

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public void onInitializeAccessibilityNodeInfo(Recycler recycler, State state, AccessibilityNodeInfoCompat info) {
    if (ViewCompat.canScrollVertically(this.mRecyclerView, -1) || ViewCompat.canScrollHorizontally(this.mRecyclerView, -1)) {
        info.addAction(8192);
        info.setScrollable(true);
    }
    if (ViewCompat.canScrollVertically(this.mRecyclerView, 1) || ViewCompat.canScrollHorizontally(this.mRecyclerView, 1)) {
        info.addAction(4096);
        info.setScrollable(true);
    }
    info.setCollectionInfo(CollectionInfoCompat.obtain(getRowCountForAccessibility(recycler, state), getColumnCountForAccessibility(recycler, state), isLayoutHierarchical(recycler, state), getSelectionModeForAccessibility(recycler, state)));
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:12,代碼來源:RecyclerView.java

示例11: canScroll

import android.support.v4.view.ViewCompat; //導入方法依賴的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:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:40,代碼來源:ViewDragHelper.java

示例12: determineEdge

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
/**
 * @return 滑動視圖是否到達邊緣
 */
private boolean determineEdge(View target, int direction) {
    switch (direction) {
        case StretchView.LEFT:
            return !ViewCompat.canScrollHorizontally(target, -1);
        case StretchView.RIGHT:
            return !ViewCompat.canScrollHorizontally(target, 1);
        case StretchView.BOTTOM:
            return !ViewCompat.canScrollVertically(target, 1);
        default:
            return false;
    }
}
 
開發者ID:thunderpunch,項目名稱:StretchView,代碼行數:16,代碼來源:StretchView.java

示例13: canChildScrollRight

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
/**
 * 是否能右拉
 *
 * @return
 */
private boolean canChildScrollRight() {
    if (checkListener != null) {
        return checkListener.canScrollRight();
    }
    return ViewCompat.canScrollHorizontally(child, 1);
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:12,代碼來源:OverScrollLayout.java

示例14: childCanScrollLeft

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public boolean childCanScrollLeft() {
    return ViewCompat.canScrollHorizontally(mScrollChild, 1);
}
 
開發者ID:zhouphenix,項目名稱:Multi-SwipeBackLayout,代碼行數:4,代碼來源:SwipeBackLayout.java

示例15: canScrollLeft

import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public boolean canScrollLeft(View view) {
    return ViewCompat.canScrollHorizontally(view, 1);
}
 
開發者ID:zhouphenix,項目名稱:Multi-SwipeToRefreshLayout,代碼行數:4,代碼來源:SwipeToRefreshLayout.java


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