Dynamically change the number of columns of a GridLayoutManager
mGridLayoutManager = new GridLayoutManager(mContext, 2);
mGridLayoutManager.setSpanSizeLookup(onSpanSizeLookup);
/**
* Helper class to set span size for grid items based on orientation and device type
*/
GridLayoutManager.SpanSizeLookup onSpanSizeLookup = new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return mHomeListAdapter.getItemViewType(position) == TYPE_PREMIUM ? 2 : 1;
}
};
If I understand your question, you would like to let premium-type Views span 2 columns instead of 1? That's possible by setting a custom SpanSizeLookup with setSpanSizeLookup(SpanSizeLookup).