下面列出了android.support.v4.view.ViewCompat#setOverScrollMode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void setOverScrollMode(int overScrollMode) {
if (overScrollMode < ViewCompat.OVER_SCROLL_ALWAYS || overScrollMode > ViewCompat.OVER_SCROLL_NEVER)
throw new IllegalArgumentException("Unknown overscroll mode: " + overScrollMode);
if (this.view == null) throw new IllegalStateException("view == null");
this.overScrollMode = overScrollMode;
ViewCompat.setOverScrollMode(view, overScrollMode);
}
public void setOverScrollMode(int overScrollMode) {
if (overScrollMode < ViewCompat.OVER_SCROLL_ALWAYS || overScrollMode > ViewCompat.OVER_SCROLL_NEVER)
throw new IllegalArgumentException("Unknown overscroll mode: " + overScrollMode);
if (this.view == null) throw new IllegalStateException("view == null");
this.overScrollMode = overScrollMode;
ViewCompat.setOverScrollMode(view, overScrollMode);
}
public void setOverScrollMode(int overScrollMode) {
if (overScrollMode < ViewCompat.OVER_SCROLL_ALWAYS || overScrollMode > ViewCompat.OVER_SCROLL_NEVER)
throw new IllegalArgumentException("Unknown overscroll mode: " + overScrollMode);
if (this.view == null) throw new IllegalStateException("view == null");
this.overScrollMode = overScrollMode;
ViewCompat.setOverScrollMode(view, overScrollMode);
}
@Override
public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) {
final int layoutDirection = dx > 0 ? 1 : -1;
View currView = getCurrentPageView();
//check if we need to work with the child view
if (recyclerView != null && currView != null && currView.canScrollHorizontally(layoutDirection)
&& ((layoutDirection == 1 && currView.getLeft() <= 0) ||
(layoutDirection == -1 && currView.getRight() >= currView.getWidth()))
) {
dOffset = 0;
if (lastTouchEvent != null) {
currView.dispatchTouchEvent(lastTouchEvent);
lastTouchEvent = null;
}
ViewCompat.setOverScrollMode(recyclerView, ViewCompat.OVER_SCROLL_NEVER);
if ((layoutDirection == 1 && currView.getLeft() < 0) || (layoutDirection == -1 && currView.getRight() > currView.getWidth())) {
adjust();
}
return 0;
} else if (Math.abs(dOffset + dx) < triggPx &&
recyclerView != null && currView != null &&
currView.getLeft() == 0 && currView.getRight() == currView.getWidth()
) {
dOffset += dx;
if (lastTouchEvent != null) {
currView.dispatchTouchEvent(lastTouchEvent);
lastTouchEvent = null;
}
ViewCompat.setOverScrollMode(recyclerView, ViewCompat.OVER_SCROLL_NEVER);
return 0;
} else {
dOffset = 0;
ViewCompat.setOverScrollMode(recyclerView, ViewCompat.OVER_SCROLL_ALWAYS);
return super.scrollHorizontallyBy(dx, recycler, state);
}
}
@Override
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
final int layoutDirection = dy > 0 ? 1 : -1;
View currView = getCurrentPageView();
//check if we need to work with the child view
if (recyclerView != null && currView != null && currView.canScrollVertically(layoutDirection)
&& ((layoutDirection == 1 && currView.getTop() <= 0) ||
(layoutDirection == -1 && currView.getBottom() >= currView.getHeight()))
) {
dOffset = 0;
if (lastTouchEvent != null) {
currView.dispatchTouchEvent(lastTouchEvent);
lastTouchEvent = null;
}
ViewCompat.setOverScrollMode(recyclerView, ViewCompat.OVER_SCROLL_NEVER);
if ((layoutDirection == 1 && currView.getTop() < 0) ||
(layoutDirection == -1 && currView.getBottom() > currView.getHeight())) {
adjust();
}
return 0;
} else if (Math.abs(dOffset + dy) < triggPy &&
recyclerView != null && currView != null &&
currView.getTop() == 0 && currView.getBottom() == currView.getHeight()
) {
dOffset += dy;
if (lastTouchEvent != null) {
currView.dispatchTouchEvent(lastTouchEvent);
lastTouchEvent = null;
}
ViewCompat.setOverScrollMode(recyclerView, ViewCompat.OVER_SCROLL_NEVER);
return 0;
} else {
dOffset = 0;
ViewCompat.setOverScrollMode(recyclerView, ViewCompat.OVER_SCROLL_ALWAYS);
return super.scrollVerticallyBy(dy, recycler, state);
}
}
public void setOverScrollMode(int overScrollMode) {
if (overScrollMode < ViewCompat.OVER_SCROLL_ALWAYS || overScrollMode > ViewCompat.OVER_SCROLL_NEVER)
throw new IllegalArgumentException("Unknown overscroll mode: " + overScrollMode);
if (this.view == null) throw new IllegalStateException("view == null");
this.overScrollMode = overScrollMode;
ViewCompat.setOverScrollMode(view, overScrollMode);
}
public void setOverScrollMode(int overScrollMode) {
if (overScrollMode < ViewCompat.OVER_SCROLL_ALWAYS || overScrollMode > ViewCompat.OVER_SCROLL_NEVER)
throw new IllegalArgumentException("Unknown overscroll mode: " + overScrollMode);
if (this.view == null) throw new IllegalStateException("view == null");
this.overScrollMode = overScrollMode;
ViewCompat.setOverScrollMode(view, overScrollMode);
}
public void setOverScrollMode(int overScrollMode) {
if (overScrollMode < ViewCompat.OVER_SCROLL_ALWAYS || overScrollMode > ViewCompat.OVER_SCROLL_NEVER)
throw new IllegalArgumentException("Unknown overscroll mode: " + overScrollMode);
if (this.view == null) throw new IllegalStateException("view == null");
this.overScrollMode = overScrollMode;
ViewCompat.setOverScrollMode(view, overScrollMode);
}