本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
示例10: canSwipeBackForThisView
import android.view.View; //导入方法依赖的package包/类
public static boolean canSwipeBackForThisView(View v, int dir) {
return !v.canScrollVertically(dir);
}
示例11: canScrollVertically
import android.view.View; //导入方法依赖的package包/类
public static boolean canScrollVertically(View v, int direction) {
return v.canScrollVertically(direction);
}
示例12: isScrollToTop
import android.view.View; //导入方法依赖的package包/类
/**
* view是否已经滚动到最顶部
*
* @param view
* @return
*/
public static boolean isScrollToTop(View view)
{
return !view.canScrollVertically(-1);
}
示例13: isScrollToBottom
import android.view.View; //导入方法依赖的package包/类
/**
* view是否已经滚动到最底部
*
* @param view
* @return
*/
public static boolean isScrollToBottom(View view)
{
return !view.canScrollVertically(1);
}