setGridSpanCount

fun setGridSpanCount(spanCount: Int)(source)

Sets the number of columns (span count) for the grid layout.

This method updates the span count of the underlying GridLayoutManager. If the current layout manager is an AutoFitGridLayoutManager, it disables automatic span calculation and forces the span count to the provided spanCount.

After updating the span count, it reconfigures the GridLayoutManager.SpanSizeLookup to ensure that items are correctly sized across the new number of columns. Finally, it notifies the adapter that the data set has changed to refresh the layout.

If the provided spanCount is the same as the current span count, or if the layout manager is not a GridLayoutManager, this method does nothing.

Parameters

spanCount

The desired number of columns in the grid.