本文整理匯總了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
}