我想用节标题实现类似网格的布局。 想想[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.我如何解决这个问题?

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐