是的,你可以做到这一点。你需要使用RecyclerView与GridLayoutManager 和你到底设置跨度大小为您的列表
第一组指定没有列在您的网格需要在你的情况下,它是2
gridLayoutManager = new GridLayoutManager(getActivity(), 2);
然后检查查看的位置,并设置跨度大小相应
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
//depanding upon the type of data set the span-size if it is header take the whole space in the row
//also check the orientation and set the span-size
if (mAdapter.getItemViewType(position) == Adapter.ITEM_VIEW_TYPE_HEADER) {
return 2;
}
}
// if the type is item type keep the span-size as normal which is one
if (mAdapter.getItemViewType(position) == Adapter.ITEM_VIEW_TYPE_ITEM) {
return 1;
}
return -1;
}
});