Setting span size of single row in StaggeredGridLayoutManager

You can use the setFullSpan method.
In this way the item will layout using all span area.

That means, if orientation is vertical, the view will have full width; if orientation is horizontal, the view will have full height.

Something like this:

public final void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {

    StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) viewHolder.itemView.getLayoutParams();
    layoutParams.setFullSpan(true);
}

Pay attention.
It supports views that span all the columns, but it should be enough for your case.


For anyone using Kotlin.

Using isFullSpan in the onBindViewHolder works.

override fun onBindViewHolder(holder: LoadStateViewHolder, loadState: LoadState) {
        holder.bind(loadState)
        val layoutParams = holder.itemView.layoutParams as StaggeredGridLayoutManager.LayoutParams
        layoutParams.isFullSpan = true
    }