Skip to content

Instantly share code, notes, and snippets.

@rezaiyan
Created September 29, 2020 09:24
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 rezaiyan/d38543252f0daa15c6cd40972aa70fb7 to your computer and use it in GitHub Desktop.
Save rezaiyan/d38543252f0daa15c6cd40972aa70fb7 to your computer and use it in GitHub Desktop.
To have a full width item in the StaggeredGridLayoutManager
ViewGroup.LayoutParams layoutParams = itemView.getLayoutParams();
if (layoutParams instanceof StaggeredGridLayoutManager.LayoutParams) {
if (getAdapterPosition() == 0) {
((StaggeredGridLayoutManager.LayoutParams) layoutParams).setFullSpan(true);
} else {
((StaggeredGridLayoutManager.LayoutParams) layoutParams).setFullSpan(false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment