當前位置: 首頁>>代碼示例>>Java>>正文


Java RecyclerView.computeVerticalScrollOffset方法代碼示例

本文整理匯總了Java中android.support.v7.widget.RecyclerView.computeVerticalScrollOffset方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.computeVerticalScrollOffset方法的具體用法?Java RecyclerView.computeVerticalScrollOffset怎麽用?Java RecyclerView.computeVerticalScrollOffset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.RecyclerView的用法示例。


在下文中一共展示了RecyclerView.computeVerticalScrollOffset方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: canScroll

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
static boolean canScroll(View view) {
    if (view instanceof ScrollView) {
        ScrollView scrollView = (ScrollView) view;
        View child = scrollView.getChildAt(0);
        if (child != null) {
            int childHeight = child.getHeight();
            return scrollView.getHeight() < childHeight + scrollView.getPaddingTop() + scrollView.getPaddingBottom();
        }
        return false;
    } else if (view instanceof RecyclerView) {
        RecyclerView recyclerView = (RecyclerView) view;
        int yOffset = recyclerView.computeVerticalScrollOffset();
        return yOffset != 0;
    }
    return true;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:Utils.java

示例2: syncOffset

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public static boolean syncOffset(SmoothAppBarLayout smoothAppBarLayout, View target, int verticalOffset, View scroll) {
  boolean isSelected = target == scroll;
  if (scroll instanceof NestedScrollView) {
    NestedScrollView nestedScrollView = (NestedScrollView) scroll;
    if (nestedScrollView.getScrollY() < verticalOffset || (!isSelected && isScrollToTop(target))) {
      nestedScrollView.scrollTo(0, verticalOffset);
    }
    if (isSelected && (nestedScrollView.getScrollY() < verticalOffset || verticalOffset == 0)) {
      nestedScrollView.scrollTo(0, 0);
      smoothAppBarLayout.syncOffset(0);
    }
  } else if (scroll instanceof RecyclerView) {
    RecyclerView recyclerView = (RecyclerView) scroll;
    boolean isAccuracy = recyclerView.getLayoutManager().findViewByPosition(ObservableRecyclerView.HEADER_VIEW_POSITION) != null;
    if (isAccuracy && recyclerView.computeVerticalScrollOffset() < verticalOffset) {
      recyclerView.scrollBy(0, verticalOffset - recyclerView.computeVerticalScrollOffset());
    } else if (!isSelected && isScrollToTop(target)) {
      recyclerView.scrollToPosition(ObservableRecyclerView.HEADER_VIEW_POSITION);
    }
    if (isAccuracy && isSelected && (recyclerView.computeVerticalScrollOffset() < verticalOffset || verticalOffset == 0)) {
      recyclerView.scrollToPosition(ObservableRecyclerView.HEADER_VIEW_POSITION);
      smoothAppBarLayout.syncOffset(0);
    }
  }
  return true;
}
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:27,代碼來源:Utils.java

示例3: onScrolled

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
	if (bubble == null || handle.isSelected())
		return;
	int verticalScrollOffset = recyclerView.computeVerticalScrollOffset();
	int verticalScrollRange = recyclerView.computeVerticalScrollRange();
	float proportion = (float) verticalScrollOffset / ((float) verticalScrollRange - height);
	setBubbleAndHandlePosition(height * proportion);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:FastScroller.java

示例4: isSlideToBottom

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * 判斷是否到底部了
 * @param recyclerView
 * @return
 */
protected boolean isSlideToBottom(RecyclerView recyclerView) {
    if (recyclerView == null) return false;
    if(mOrientation == LinearLayoutManager.VERTICAL) {
        if (recyclerView.computeVerticalScrollExtent() + recyclerView.computeVerticalScrollOffset() >= recyclerView.computeVerticalScrollRange())
            return true;
    }
    else
    {
        if (recyclerView.computeHorizontalScrollExtent() + recyclerView.computeHorizontalScrollOffset() >= recyclerView.computeHorizontalScrollRange())
            return true;
    }
    return false;
}
 
開發者ID:wanliyang1990,項目名稱:RecyclerViewHeaderAndFooter,代碼行數:19,代碼來源:WapHeaderAndFooterAdapter.java

示例5: onScrolled

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) {
  if (handle.isSelected()) return;
  final int   offset      = recyclerView.computeVerticalScrollOffset();
  final int   range       = recyclerView.computeVerticalScrollRange();
  final int   extent      = recyclerView.computeVerticalScrollExtent();
  final int   offsetRange = Math.max(range - extent, 1);
  setBubbleAndHandlePosition((float) Util.clamp(offset, 0, offsetRange) / offsetRange);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:10,代碼來源:RecyclerViewFastScroller.java

示例6: isMaxScrollReached

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
static private boolean isMaxScrollReached(RecyclerView recyclerView) {
    int maxScroll = recyclerView.computeVerticalScrollRange();

    int currentScroll = recyclerView.computeVerticalScrollOffset() + recyclerView.computeVerticalScrollExtent();

    android.util.Log.d(TAG, maxScroll + ", " + currentScroll);
    if (maxScroll == 0)
        return false;
    return currentScroll >= maxScroll;
}
 
開發者ID:AppHero2,項目名稱:Raffler-Android,代碼行數:11,代碼來源:ChatFragment.java

示例7: rvPullDownIntercept

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public boolean rvPullDownIntercept(View child) {
    boolean intercept = false;

    RecyclerView recyclerChild = (RecyclerView) child;
    if (recyclerChild.computeVerticalScrollOffset() <= 0)
        intercept = true;

    return intercept;
}
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:10,代碼來源:InterceptLayout.java

示例8: rvPullUpIntercept

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public boolean rvPullUpIntercept(View child) {
    boolean intercept = false;

    RecyclerView recyclerChild = (RecyclerView) child;
    if (recyclerChild.computeVerticalScrollExtent() + recyclerChild.computeVerticalScrollOffset()
            >= recyclerChild.computeVerticalScrollRange())
        intercept = true;

    return intercept;
}
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:11,代碼來源:InterceptLayout.java

示例9: onScrolled

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    if (scrollerView.isSelected()) return;
    int verticalScrollOffset = recyclerView.computeVerticalScrollOffset();
    int verticalScrollRange = recyclerView.computeVerticalScrollRange();
    float proportion = (float) verticalScrollOffset / ((float) verticalScrollRange - height);
    setScrollerHeight(height * proportion);
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:8,代碼來源:RecyclerViewFastScroller.java

示例10: onScrolled

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public final void onScrolled(RecyclerView recyclerView, int dx, int dy)
{
	int toolbarYOffset = (int) (dy - toolbar.getTranslationY());
	
	state.verticalOffset = recyclerView.computeVerticalScrollOffset();
	state.scrollingOffset = dy;
	
	toolbar.animate().cancel();
	if (state.scrollingOffset > 0) 
	{
		if (toolbarYOffset < toolbar.getHeight()) 
		{
			if (state.verticalOffset > toolbar.getHeight()) 
			{
				setElevation(TOOLBAR_ELEVATION);
			}
			toolbar.setTranslationY(state.translationY = -toolbarYOffset);
		} 
		else 
		{
			setElevation(5);
			toolbar.setTranslationY(state.translationY = -toolbar.getHeight());
		}
	} 
	else if (state.scrollingOffset < 0) 
	{
		if (toolbarYOffset < 0)
		{
			if (state.verticalOffset <= 0) 
			{
				setElevation(5);
			}
			toolbar.setTranslationY(state.translationY = 0);
		} 
		else 
		{
			if (state.verticalOffset > toolbar.getHeight()) 
			{
				setElevation(TOOLBAR_ELEVATION);
			}
			toolbar.setTranslationY(state.translationY = -toolbarYOffset);
		}
	}
}
 
開發者ID:MSay2,項目名稱:Mire,代碼行數:46,代碼來源:RecyclerViewUtils.java


注:本文中的android.support.v7.widget.RecyclerView.computeVerticalScrollOffset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。