private void retrieveItemHeight(final RecyclerView.ViewHolder holder) { mOriginalY = mRecyclerView.getLayoutManager().getDecoratedBottom(holder.itemView); }
View lastChild = rv.getChildAt(rv.getChildCount() - 1); return (rv.getAdapter().getItemCount() - 1) * lm.getDecoratedMeasuredHeight(lastChild) + lm.getDecoratedBottom(lastChild) - rv.getBottom();
@Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { if (parent.isAnimating()) return; final int childCount = parent.getChildCount(); final RecyclerView.LayoutManager lm = parent.getLayoutManager(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); RecyclerView.ViewHolder viewHolder = parent.getChildViewHolder(child); if (requiresDivider(viewHolder)) { final int right = lm.getDecoratedRight(child); final int bottom = lm.getDecoratedBottom(child); // draw the bottom divider canvas.drawRect(lm.getDecoratedLeft(child), bottom - dividerSize, right, bottom, paint); // draw the right edge divider canvas.drawRect(right - dividerSize, lm.getDecoratedTop(child), right, bottom - dividerSize, paint); } } }
View lastChild = rv.getChildAt(rv.getChildCount() - 1); return (rv.getAdapter().getItemCount() - 1) * lm.getDecoratedMeasuredHeight(lastChild) + lm.getDecoratedBottom(lastChild) - rv.getBottom();
View lastChild = rv.getChildAt(rv.getChildCount() - 1); return (rv.getAdapter().getItemCount() - 1) * lm.getDecoratedMeasuredHeight(lastChild) + lm.getDecoratedBottom(lastChild) - rv.getBottom();
View lastChild = rv.getChildAt(rv.getChildCount() - 1); return (rv.getAdapter().getItemCount() - 1) * lm.getDecoratedMeasuredHeight(lastChild) + lm.getDecoratedBottom(lastChild) - rv.getBottom();
View lastChild = rv.getChildAt(rv.getChildCount() - 1); return (rv.getAdapter().getItemCount() - 1) * lm.getDecoratedMeasuredHeight(lastChild) + lm.getDecoratedBottom(lastChild) - rv.getBottom();
final int decoratedBottom = parent.getLayoutManager().getDecoratedBottom(child); drawBottom(c, left, right, child, decoratedBottom);
- Math.max(0, paddingBottom + layoutManager.getDecoratedBottom(itemView) - height); // How much is cut at the bottom
View lastChild = rv.getChildAt(rv.getChildCount() - 1); return (rv.getAdapter().getItemCount() - 1) * lm.getDecoratedMeasuredHeight(lastChild) + lm.getDecoratedBottom(lastChild) - rv.getBottom();
/** * Calculates the vertical scroll amount necessary to make the given view fully visible * inside the RecyclerView. * * @param view The view which we want to make fully visible * @param snapPreference The edge which the view should snap to when entering the visible * area. One of {@link #SNAP_TO_START}, {@link #SNAP_TO_END} or * {@link #SNAP_TO_ANY}. * @return The vertical scroll amount necessary to make the view visible with the given * snap preference. */ public int calculateDyToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollVertically()) { return 0; } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int top = layoutManager.getDecoratedTop(view) - params.topMargin; final int bottom = layoutManager.getDecoratedBottom(view) + params.bottomMargin; final int start = layoutManager.getPaddingTop(); final int end = layoutManager.getHeight() - layoutManager.getPaddingBottom(); return calculateDtToFit(top, bottom, start, end, snapPreference); }
/** * Calculates the vertical scroll amount necessary to make the given view in center of the RecycleView * * @param view The view which we want to make in center of the RecycleView * @return The vertical scroll amount necessary to make the view in center of the RecycleView */ public int calculateDyToMakeCentral(View view) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollVertically()) { return 0; } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int top = layoutManager.getDecoratedTop(view) - params.topMargin; final int bottom = layoutManager.getDecoratedBottom(view) + params.bottomMargin; final int start = layoutManager.getPaddingTop(); final int end = layoutManager.getHeight() - layoutManager.getPaddingBottom(); final int childCenter = top + (int) ((bottom - top) / 2.0f); final int containerCenter = (int) ((end - start) / 2.f); return containerCenter - childCenter; }
private int adjustDyForUp(int dy) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollVertically()) { return 0; } final View lastChild = layoutManager.getChildAt(layoutManager.getChildCount() - 1); final int position = layoutManager.getPosition(lastChild); if (position == layoutManager.getItemCount() - 1) { final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) lastChild.getLayoutParams(); final int maxDy = layoutManager.getHeight() - layoutManager.getPaddingBottom() - (layoutManager.getDecoratedBottom(lastChild) + params.bottomMargin); if (dy < maxDy) { return maxDy; } } return dy; }
@Override public int calculateDyToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollVertically()) { return 0; } final int adapterPosition = getPosition(view); final int topOffset = getPositionSectionHeaderHeight(adapterPosition); final int top = layoutManager.getDecoratedTop(view); final int bottom = layoutManager.getDecoratedBottom(view); final int start = layoutManager.getPaddingTop() + topOffset; final int end = layoutManager.getHeight() - layoutManager.getPaddingBottom(); return calculateDtToFit(top, bottom, start, end, snapPreference); } };
private void retrieveItemHeight(final RecyclerView.ViewHolder holder) { mOriginalY = mRecyclerView.getLayoutManager().getDecoratedBottom(holder.itemView); }
@Override public int calculateDyToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollVertically()) { return 0; } final int adapterPosition = getPosition(view); final int topOffset = getPositionSectionHeaderHeight(adapterPosition); final int top = layoutManager.getDecoratedTop(view); final int bottom = layoutManager.getDecoratedBottom(view); final int start = layoutManager.getPaddingTop() + topOffset; final int end = layoutManager.getHeight() - layoutManager.getPaddingBottom(); return calculateDtToFit(top, bottom, start, end, snapPreference); } };
@Override public int getDecoratedEnd(View view) { final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); return mLayoutManager.getDecoratedBottom(view) + params.bottomMargin; }
@Override public int getDecoratedEnd(View view) { final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); return mLayoutManager.getDecoratedBottom(view) + params.bottomMargin; }
@Override public int getDecoratedEnd(View view) { final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); return mLayoutManager.getDecoratedBottom(view) + params.bottomMargin; }
? view.getHeight() - layoutManager.getPaddingBottom() - layoutManager.getDecoratedBottom(firstView) : layoutManager.getDecoratedTop(firstView) - layoutManager.getPaddingTop();