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.

Can you give any suggestion on how to implement this?

+3


source to share


4 answers


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

0


source


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.

+1


source


If you don't need RecycleView, this is another option: https://github.com/sarahlensing/StaggeredGridView

0


source


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);

      

0


source







All Articles