Skip to content

Instantly share code, notes, and snippets.

@DevAhamed
Created June 7, 2017 09:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DevAhamed/6b28bfdc0dc46e85fc29c8df8718ac6b to your computer and use it in GitHub Desktop.
Save DevAhamed/6b28bfdc0dc46e85fc29c8df8718ac6b to your computer and use it in GitHub Desktop.
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
canvas.save();
final int leftWithMargin = convertDpToPixel(56);
final int right = parent.getWidth();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
int adapterPosition = parent.getChildAdapterPosition(child);
left = (adapterPosition == lastPosition) ? 0 : leftWithMargin;
parent.getDecoratedBoundsWithMargins(child, mBounds);
final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child));
final int top = bottom - mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
canvas.restore();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment