答案 0 :(得分:1)
final SpannableGridLayoutManager.LayoutParams lp = (SpannableGridLayoutManager.LayoutParams)itemView.getLayoutParams();
final int span1 = (itemId == 0 || itemId == 3 ? 2 : 1);
final int span2 = (itemId == 0 ? 2 : (itemId == 3 ? 3 : 1));
final int colSpan = (isVertical ? span2 : span1);
final int rowSpan = (isVertical ? span1 : span2);
if (lp.rowSpan != rowSpan || lp.colSpan != colSpan) {
lp.rowSpan = rowSpan;
lp.colSpan = colSpan;
itemView.setLayoutParams(lp);
}