本文整理汇总了Java中android.support.v4.view.ViewCompat.canScrollVertically方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.canScrollVertically方法的具体用法?Java ViewCompat.canScrollVertically怎么用?Java ViewCompat.canScrollVertically使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.canScrollVertically方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canChildScrollUp
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* Whether child view can scroll up
* @return
*/
public boolean canChildScrollUp() {
if (mTargetView == null) {
return false;
}
if (Build.VERSION.SDK_INT < 14) {
if (mTargetView instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTargetView;
return absListView.getChildCount() > 0
&& (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
.getTop() < absListView.getPaddingTop());
} else {
return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0;
}
} else {
return ViewCompat.canScrollVertically(mTargetView, -1);
}
}
示例2: canChildScrollUp
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public boolean canChildScrollUp() {
boolean z = false;
if (VERSION.SDK_INT >= 14) {
return ViewCompat.canScrollVertically(this.mTarget, -1);
}
if (this.mTarget instanceof AbsListView) {
AbsListView absListView = this.mTarget;
if (absListView.getChildCount() <= 0 || (absListView.getFirstVisiblePosition() <= 0 && absListView.getChildAt(0).getTop() >= absListView.getPaddingTop())) {
return false;
}
return true;
}
if (ViewCompat.canScrollVertically(this.mTarget, -1) || this.mTarget.getScrollY() > 0) {
z = true;
}
return z;
}
示例3: canChildScrollUp
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* 判断View是否可以上拉
* @return canChildScrollUp
*/
public boolean canChildScrollUp() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
if (mTargetView instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTargetView;
return absListView.getChildCount() > 0
&& (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
.getTop() < absListView.getPaddingTop());
} else {
return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0;
}
} else {
return ViewCompat.canScrollVertically(mTargetView, -1);
}
}
示例4: canChildScrollUp
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* @return Whether it is possible for the child view of this layout to
* scroll up. Override this if the child view is a custom view.
*/
public boolean canChildScrollUp() {
if (android.os.Build.VERSION.SDK_INT < 14) {
if (mTarget instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTarget;
return absListView.getChildCount() > 0
&& (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
.getTop() < absListView.getPaddingTop());
} else {
return mTarget.getScrollY() > 0;
}
} else {
return ViewCompat.canScrollVertically(mTarget, -1);
}
}
示例5: onNestedPreScroll
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) {
boolean hiddenTop = dy > 0 && getScrollY() < mTopViewHeight;
boolean showTop = dy < 0 && getScrollY() >= 0 && !ViewCompat.canScrollVertically(target, -1);
if (hiddenTop || showTop) {
scrollBy(0, dy);
consumed[1] = dy;
}
}
示例6: canChildScroll
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private static boolean canChildScroll(View view, int direction) {
if (view == null) {
return false;
}
if (view instanceof ViewGroup) {
final ViewGroup vGroup = (ViewGroup) view;
View child;
boolean result;
for (int i = 0; i < vGroup.getChildCount(); i++) {
child = vGroup.getChildAt(i);
if (child instanceof RecyclerView) {
result = ViewCompat.canScrollVertically(child, direction);
} else if (child instanceof ViewGroup) {
result = canChildScroll(child, direction);
} else if (child instanceof View) {
result = ViewCompat.canScrollVertically(child, direction);
} else {
result = canChildScroll(child, direction);
}
if (result) {
return true;
}
}
}
return ViewCompat.canScrollVertically(view, direction);
}
示例7: onNestedPreScroll
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed)
{
super.onNestedPreScroll(target, dx, dy, consumed);
Log.e(TAG, "onNestedPreScroll");
boolean hiddenTop = dy > 0 && getScrollY() < mTopViewHeight;
boolean showTop = dy < 0 && getScrollY() >= 0 && !ViewCompat.canScrollVertically(target, -1);
if (hiddenTop || showTop)
{
scrollBy(0, dy);
consumed[1] = dy;
}
}
示例8: onInitializeAccessibilityEvent
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void onInitializeAccessibilityEvent(Recycler recycler, State state, AccessibilityEvent event) {
boolean z = true;
AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
if (this.mRecyclerView != null && record != null) {
if (!(ViewCompat.canScrollVertically(this.mRecyclerView, 1) || ViewCompat.canScrollVertically(this.mRecyclerView, -1) || ViewCompat.canScrollHorizontally(this.mRecyclerView, -1) || ViewCompat.canScrollHorizontally(this.mRecyclerView, 1))) {
z = false;
}
record.setScrollable(z);
if (this.mRecyclerView.mAdapter != null) {
record.setItemCount(this.mRecyclerView.mAdapter.getItemCount());
}
}
}
示例9: canChildScrollUp
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean canChildScrollUp() {
if (mScrollUpChild != null) {
return ViewCompat.canScrollVertically(mScrollUpChild, -1);
}
return super.canChildScrollUp();
}
示例10: manageScrollIndicators
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private static void manageScrollIndicators(View v, View upIndicator, View downIndicator) {
int i = 0;
if (upIndicator != null) {
upIndicator.setVisibility(ViewCompat.canScrollVertically(v, -1) ? 0 : 4);
}
if (downIndicator != null) {
if (!ViewCompat.canScrollVertically(v, 1)) {
i = 4;
}
downIndicator.setVisibility(i);
}
}
示例11: 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;
}
示例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;
}
}
示例13: canChildScrollDown
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* Whether it is possible for the child view of this layout to
* scroll down. Override this if the child view is a custom view.
*
* @return
*/
protected boolean canChildScrollDown() {
if (android.os.Build.VERSION.SDK_INT < 14) {
if (mTargetView instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTargetView;
return absListView.getChildCount() > 0
&& (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
|| absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
} else {
return ViewCompat.canScrollVertically(mTargetView, 1) || mTargetView.getScrollY() < 0;
}
} else {
return ViewCompat.canScrollVertically(mTargetView, 1);
}
}
示例14: childCanScrollDown
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public boolean childCanScrollDown() {
return ViewCompat.canScrollVertically(mScrollChild, -1);
}
示例15: onInitializeAccessibilityNodeInfo
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* Called by the AccessibilityDelegate when the information about the current layout should
* be populated.
* <p>
* Default implementation adds a {@link
* android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.CollectionInfoCompat}.
* <p>
* You should override
* {@link #getRowCountForAccessibility(RecyclerView.Recycler, RecyclerView.State)},
* {@link #getColumnCountForAccessibility(RecyclerView.Recycler, RecyclerView.State)},
* {@link #isLayoutHierarchical(RecyclerView.Recycler, RecyclerView.State)} and
* {@link #getSelectionModeForAccessibility(RecyclerView.Recycler, RecyclerView.State)} for
* more accurate accessibility information.
*
* @param recycler The Recycler that can be used to convert view positions into adapter
* positions
* @param state The current state of RecyclerView
* @param info The info that should be filled by the LayoutManager
* @see View#onInitializeAccessibilityNodeInfo(
*android.view.accessibility.AccessibilityNodeInfo)
* @see #getRowCountForAccessibility(RecyclerView.Recycler, RecyclerView.State)
* @see #getColumnCountForAccessibility(RecyclerView.Recycler, RecyclerView.State)
* @see #isLayoutHierarchical(RecyclerView.Recycler, RecyclerView.State)
* @see #getSelectionModeForAccessibility(RecyclerView.Recycler, RecyclerView.State)
*/
public void onInitializeAccessibilityNodeInfo(Recycler recycler, State state,
AccessibilityNodeInfoCompat info) {
if (ViewCompat.canScrollVertically(mRecyclerView, -1) ||
ViewCompat.canScrollHorizontally(mRecyclerView, -1)) {
info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
info.setScrollable(true);
}
if (ViewCompat.canScrollVertically(mRecyclerView, 1) ||
ViewCompat.canScrollHorizontally(mRecyclerView, 1)) {
info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
info.setScrollable(true);
}
final AccessibilityNodeInfoCompat.CollectionInfoCompat collectionInfo
= AccessibilityNodeInfoCompat.CollectionInfoCompat
.obtain(getRowCountForAccessibility(recycler, state),
getColumnCountForAccessibility(recycler, state),
isLayoutHierarchical(recycler, state),
getSelectionModeForAccessibility(recycler, state));
info.setCollectionInfo(collectionInfo);
}