decoratedTop = lm.getDecoratedTop(child) + (int) child.getTranslationY(); decoratedRight = lm.getDecoratedRight(child) + (int) child.getTranslationX(); decoratedBottom = lm.getDecoratedBottom(child) + (int) child.getTranslationY();
lm.getDecoratedTop(child), lm.getDecoratedRight(child), lm.getDecoratedBottom(child), paint ); bottom, right, lm.getDecoratedBottom(child) + child.getTranslationY(), 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); } } }
@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); } };
recyclerView.scrollToPosition(toPos); final int maxBottom = layoutManager.getDecoratedBottom(target.itemView); if (maxBottom >= recyclerView.getHeight() - recyclerView.getPaddingBottom()) { 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); } } }