Skip to content

Instantly share code, notes, and snippets.

@chemickypes
Created June 27, 2017 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemickypes/c6acf04cd3604aa4a4e728b9937b259a to your computer and use it in GitHub Desktop.
Save chemickypes/c6acf04cd3604aa4a4e728b9937b259a to your computer and use it in GitHub Desktop.
Code for Medium article 2
...
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
int dataSize = state.getItemCount();
int position = parent.getChildAdapterPosition(view);
if (dataSize > 0 && position == dataSize - 1) {
outRect.set(0, 0, mEndOffset, 0);
} else {
outRect.set(0, 0, 0, 0);
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment