我想用节标题实现类似网格的布局。想想https://github.com/TonicArtos/StickyGridHeaders
我现在应该做什么:
mRecyclerView = (RecyclerView) view.findViewById(R.id.grid);
mLayoutManager = new GridLayoutManager(getActivity(), 2);
mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
switch(mAdapter.getItemViewType(position)){
case MyAdapter.TYPE_HEADER:
return 1;
case MyAdapter.TYPE_ITEM:
return 2;
default:
return -1;
}
}
});
mRecyclerView.setLayoutManager(mLayoutManager);
现在常规项目和标题的跨度大小都是 1。我该如何解决这个问题?