I am setting up contact directory in section recyclerview with grid layout manager, what my problem is that header is also set as an item in the span if the span is empty.
I tried using the SpanSizeLookup method. It's not working as I expected.
layoutManager = new GridLayoutManager(getActivity(), 3);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
switch(adapterDocument.getItemViewType(position)){
case SectionedRecyclerViewAdapter.VIEW_TYPE_HEADER:
return 3;
case SectionedRecyclerViewAdapter.VIEW_TYPE_ITEM_LOADED:
return 1;
default:
return 1;
}
}
});
This is what I get
And this is what I really wants:
How to make header should be in next line with full width? Thank you.
there is something with your code, I changed the code in
onCreateView
from Example1 to:and it's working fine, this is the result: