decoratedLeft = lm.getDecoratedLeft(child) + (int) child.getTranslationX(); decoratedTop = lm.getDecoratedTop(child) + (int) child.getTranslationY(); decoratedRight = lm.getDecoratedRight(child) + (int) child.getTranslationX(); decoratedBottom = lm.getDecoratedBottom(child) + (int) child.getTranslationY();
@Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { int childCount = parent.getChildCount(); RecyclerView.LayoutManager lm = parent.getLayoutManager(); for (int i = 0; i < childCount; i++) { View child = parent.getChildAt(i); int right = (int) (lm.getDecoratedRight(child) + child.getTranslationX()); if (i == childCount - 1) { // Last item right = Math.max(right, parent.getWidth()); } // Right border c.drawRect(child.getRight() + child.getTranslationX(), 0, right, parent.getHeight(), grayBackgroundPaint); } } }
lm.getDecoratedLeft(child), lm.getDecoratedTop(child), lm.getDecoratedRight(child), lm.getDecoratedBottom(child), paint paint); float right = lm.getDecoratedRight(child) + child.getTranslationX(); if (isLast) { right = Math.max(right, parent.getWidth());
recyclerView.scrollToPosition(toPos); final int maxRight = layoutManager.getDecoratedRight(target.itemView); if (maxRight >= recyclerView.getWidth() - recyclerView.getPaddingRight()) { recyclerView.scrollToPosition(toPos);
@Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { for (int i = 0; i < parent.getChildCount(); i++) { View child = parent.getChildAt(i); if (!isHeader(child, parent)) continue; RecyclerView.LayoutManager lm = parent.getLayoutManager(); float top = lm.getDecoratedTop(child) + child.getTranslationY(); float bottom = lm.getDecoratedBottom(child) + child.getTranslationY(); if (i == parent.getChildCount() - 1) { // Draw to bottom if last item bottom = Math.max(parent.getHeight(), bottom); } float right = lm.getDecoratedRight(child) + child.getTranslationX(); float left = lm.getDecoratedLeft(child) + child.getTranslationX(); c.drawRect(left, top, right, bottom, paint); } } }
@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 (viewHolder instanceof Divided) { 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); } } }