So what I am trying to go for is having a staggered layout but the first item in the list needs to span two columns. The first two rows are also a fixed height. I have every
The solution proposed by ljmelgui works fine but can be mixed with mato answer for a minor optimization by trying to reuse the layoutParams in case they exist:
public final void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) viewHolder.itemView.getLayoutParams();
if ( layoutParams == null ) {
layoutParams = new StaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}
layoutParams.setFullSpan(true);
viewHolder.itemView.setLayoutParams(layoutParams);
}