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


Java View.canScrollVertically方法代码示例

本文整理汇总了Java中android.view.View.canScrollVertically方法的典型用法代码示例。如果您正苦于以下问题:Java View.canScrollVertically方法的具体用法?Java View.canScrollVertically怎么用?Java View.canScrollVertically使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.canScrollVertically方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canChildScrollUp

import android.view.View; //导入方法依赖的package包/类
public static boolean canChildScrollUp(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else if(view instanceof  RecyclerView){
            RecyclerView recyclerView = (RecyclerView)view;
            RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
            if(layoutManager instanceof LinearLayoutManager){
                int position = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
                return position != 0;
            }else{
                if(layoutManager instanceof StaggeredGridLayoutManager ){
                    StaggeredGridLayoutManager stagger = (StaggeredGridLayoutManager) layoutManager;
                    int[] positions = stagger.findFirstCompletelyVisibleItemPositions(null);
                    return positions[0] != 0;
                }else{
                    throw new RuntimeException("can not support this LayoutManager ");
                }
            }
        }else{
            return view.getScrollY() > 0;
        }
    } else {
        return view.canScrollVertically(-1);
    }
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:30,代码来源:PtrDefaultHandler.java

示例2: canScrollUp

import android.view.View; //导入方法依赖的package包/类
public static boolean canScrollUp(View targetView) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (targetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) targetView;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return targetView.getScrollY() > 0;
        }
    } else {
        return targetView.canScrollVertically(-1);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:ScrollBoundaryUtil.java

示例3: canScrollDown

import android.view.View; //导入方法依赖的package包/类
public static boolean canScrollDown(View targetView) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (targetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) targetView;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else {
            return targetView.getScrollY() < 0;
        }
    } else {
        return targetView.canScrollVertically(1);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:ScrollBoundaryUtil.java

示例4: canChildScrollUp

import android.view.View; //导入方法依赖的package包/类
public static boolean canChildScrollUp(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return view.getScrollY() > 0;
        }
    } else {
        return view.canScrollVertically(-1);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:PtrDefaultHandler.java

示例5: tryCaptureView

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean tryCaptureView(View child, int pointerId) {
  if (mState == STATE_DRAGGING) {
    return false;
  }
  if (mTouchingScrollingChild) {
    return false;
  }
  if (mState == STATE_EXPANDED && mActivePointerId == pointerId) {
    View scroll = mNestedScrollingChildRef.get();
        if (scroll != null && scroll.canScrollVertically(-1)) {
      // Let the content scroll up
      return false;
    }
  }
  return mViewRef != null && mViewRef.get() == child;
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:18,代码来源:BottomSheetBehavior.java

示例6: canScrollUp

import android.view.View; //导入方法依赖的package包/类
private static boolean canScrollUp(View targetView) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (targetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) targetView;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return targetView.getScrollY() > 0;
        }
    } else {
        return targetView.canScrollVertically(-1);
    }
}
 
开发者ID:Brave-wan,项目名称:SmartRefresh,代码行数:15,代码来源:RefreshContentWrapper.java

示例7: canScrollDown

import android.view.View; //导入方法依赖的package包/类
private static boolean canScrollDown(View mScrollableView) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mScrollableView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mScrollableView;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else {
            return mScrollableView.getScrollY() < 0;
        }
    } else {
        return mScrollableView.canScrollVertically(1);
    }
}
 
开发者ID:Brave-wan,项目名称:SmartRefresh,代码行数:15,代码来源:RefreshContentWrapper.java

示例8: onNestedPreScroll

import android.view.View; //导入方法依赖的package包/类
@Override
  public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx,
          int dy, int[] consumed) {
  View scrollingChild = mNestedScrollingChildRef.get();
  if (target != scrollingChild) {
    return;
  }
  int currentTop = child.getTop();
  int newTop = currentTop - dy;
  if (dy > 0) { // Upward
    if (newTop < mMinOffset) {
      consumed[1] = currentTop - mMinOffset;
      ViewCompat.offsetTopAndBottom(child, -consumed[1]);
      setStateInternal(STATE_EXPANDED);
    } else {
      consumed[1] = dy;
      ViewCompat.offsetTopAndBottom(child, -dy);
      setStateInternal(STATE_DRAGGING);
    }
  } else if (dy < 0) { // Downward
          if (!target.canScrollVertically(-1)) {
      if (newTop <= mMaxOffset || mHideable) {
        consumed[1] = dy;
        ViewCompat.offsetTopAndBottom(child, -dy);
        setStateInternal(STATE_DRAGGING);
      } else {
        consumed[1] = currentTop - mMaxOffset;
        ViewCompat.offsetTopAndBottom(child, -consumed[1]);
        setStateInternal(STATE_COLLAPSED);
      }
    }
  }
  dispatchOnSlide(child.getTop());
  mLastNestedScrollDy = dy;
  mNestedScrolled = true;
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:37,代码来源:BottomSheetBehavior.java

示例9: onLayout

import android.view.View; //导入方法依赖的package包/类
/**
 * To be called after the View has been laid out. If the view is presumably to small,
 * this will call {@link #onSpaceOver(View)} for you.
 *
 * @param view The view that has been laid out
 */
public static void onLayout(View view) {
    if (view.getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT) {
        // TODO: don't do this if getMaxLines is >= 0 (< MAX_VALUE). Same for getMaxheight.
        if (view.canScrollVertically(-1) || view.canScrollVertically(1)) {
            LOG.w("onLayout:", preview(view), "We can scroll. Notifying the parent column.");
            onSpaceOver(view);
        }
    }
}
 
开发者ID:natario1,项目名称:ViewPrinter,代码行数:16,代码来源:DocumentHelper.java

示例10: canSwipeBackForThisView

import android.view.View; //导入方法依赖的package包/类
public static boolean canSwipeBackForThisView(View v, int dir) {
    return !v.canScrollVertically(dir);
}
 
开发者ID:nichbar,项目名称:Aequorea,代码行数:4,代码来源:SwipeBackCoordinatorLayout.java

示例11: canScrollVertically

import android.view.View; //导入方法依赖的package包/类
public static boolean canScrollVertically(View v, int direction) {
    return v.canScrollVertically(direction);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:ViewCompatICS.java

示例12: isScrollToTop

import android.view.View; //导入方法依赖的package包/类
/**
 * view是否已经滚动到最顶部
 *
 * @param view
 * @return
 */
public static boolean isScrollToTop(View view)
{
    return !view.canScrollVertically(-1);
}
 
开发者ID:zj565061763,项目名称:switchbutton,代码行数:11,代码来源:FTouchHelper.java

示例13: isScrollToBottom

import android.view.View; //导入方法依赖的package包/类
/**
 * view是否已经滚动到最底部
 *
 * @param view
 * @return
 */
public static boolean isScrollToBottom(View view)
{
    return !view.canScrollVertically(1);
}
 
开发者ID:zj565061763,项目名称:switchbutton,代码行数:11,代码来源:FTouchHelper.java


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