How i can make dynamic number of columns in RecyclerView
using StaggeredGridLayoutManager
. I already have working RecyclerView
. Here i
if max columns are two that would be quite simple.For the view that occupy the full width,setFullSpan(true) like in your BindView method of Recyclerview Adapter
//rlm is RecyclerView.LayoutManager passed in constructor or setter in adapter
if (rlm instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
/*
* to make View to occupy full width of the parent
*/
layoutParams.setFullSpan(true);
}