【发布时间】:2020-12-10 01:27:59
【问题描述】:
我需要每 18,36,54,...18*Nth... 网格布局,宽度:匹配父级和高度:60dp 在网格布局管理器中用于分页加载栏目的。
这是我的代码,
GridLayoutManager mng_layout = new GridLayoutManager(this, 4);//WHAT IS 4 ?//
mng_layout.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
int mod = position % 6; //WHAT IS 6 ?//
if (position == 0 || position == 1)
return 2; //WHAT IS 2 ?//
else if (position < 6)
return 1; //WHAT IS 1 ?//
else if (mod == 0 || mod == 1)
return 2; //WHAT IS 2 ?//
else
return 1; //WHAT IS 1 ?//
}
});
如果有人有时间,请解释代码中的注释行
【问题讨论】:
标签: android android-recyclerview gridlayoutmanager