How do I implement a Staggered GridView with sections?
I just want to implement sections in a Shaggered GridView. , for example Today, Yesterday and Other. I tried with below library but I had no luck.
- Spaced GridView
- RecyclerView with StaggeredGridLayoutManager.
Can you give any suggestion on how to implement this?
source to share
I have implemented this using a RecyclerView with StaggeredGridLayoutManger in SimpleAdapter.java .
if (position % 5 == 0) {
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
layoutParams.setFullSpan(true);
} else {
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
layoutParams.setFullSpan(false);
}
Here is the link I created for this StaggeredGridViewSections
source to share
You can use StaggeredGridLayoutManager with custom ItemDecoration.
Here's a library that does it with LinearLayoutManager, sticky-headers-recyclerview . You may be able to customize it to your needs, or at least have an idea of how to do it.
source to share
If you don't need RecycleView, this is another option: https://github.com/sarahlensing/StaggeredGridView
source to share
You can use the StaggeredGridLayoutManager with one adapter and set two ItemViewTypes and set the full range to true for the section slice.
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
layoutParams.setFullSpan(true);
source to share