当前位置: 首页>>代码示例>>Java>>正文


Java ViewCompat.canScrollVertically方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:22,代码来源:WXSwipeLayout.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:SwipeRefreshLayout.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SlidingLayout.java

示例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);
    }
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:19,代码来源:SwipeRefreshLayout.java

示例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;
    }
}
 
开发者ID:zuoni1018,项目名称:CoordinatorLayoutExample-master,代码行数:11,代码来源:StickyNavLayout.java

示例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);
    }
 
开发者ID:angcyo,项目名称:DexFixDemo,代码行数:31,代码来源:UI.java

示例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;
    }
}
 
开发者ID:halohoop,项目名称:AndroidDigIn,代码行数:15,代码来源:NestedScrollLayout.java

示例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());
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:14,代码来源:RecyclerView.java

示例9: canChildScrollUp

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean canChildScrollUp() {
    if (mScrollUpChild != null) {
        return ViewCompat.canScrollVertically(mScrollUpChild, -1);
    }
    return super.canChildScrollUp();
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:8,代码来源:ScrollChildSwipeRefreshLayout.java

示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:AlertController.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:33,代码来源:RecyclerView.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: 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);
    }
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:21,代码来源:SwipeToLoadLayout.java

示例14: childCanScrollDown

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public boolean childCanScrollDown() {
    return ViewCompat.canScrollVertically(mScrollChild, -1);
}
 
开发者ID:zhouphenix,项目名称:Multi-SwipeBackLayout,代码行数:4,代码来源:SwipeBackLayout.java

示例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);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:46,代码来源:RecyclerView.java


注:本文中的android.support.v4.view.ViewCompat.canScrollVertically方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。