Reputation: 83
I am developing E Commerce app. In my app I needs to show items in grid view manner. But i needs to show one horizontal item (like add)after every four items in grid view manner using recyclerview card view. adds means I am not using google add mob. I am just show an item like a add in horizontal manner. I am confused. any one can help me.
Upvotes: 0
Views: 430
Reputation: 69709
you can use StaggeredGridLayoutManager
private StaggeredGridLayoutManager gaggeredGridLayoutManager;
gaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, 1);
recyclerView.setLayoutManager(gaggeredGridLayoutManager);
for more information follow this link StaggeredGridLayoutManager
Upvotes: 0
Reputation: 13555
You can use Recyclerview or Gridview with sticky headers
<dependency>
<groupId>com.tonicartos</groupId>
<artifactId>stickygridheaders</artifactId>
<version>1.0.1</version>
</dependency>
https://github.com/DWorkS/AStickyHeader
http://tonicartos.github.io/StickyGridHeaders/
https://github.com/ShamylZakariya/StickyHeaders
https://github.com/timehop/sticky-headers-recyclerview
Upvotes: 0
Reputation: 525
Try like this.
RecyclerView mRecyclerView = (RecyclerView) rootView.findViewById(R.id.card_recycler_view);
GridLayoutManager glm = new GridLayoutManager(getActivity(), 4);
glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (position % 5 == 4) {
return 4;
} else {
return 2;
}
}
});
mRecyclerView.setLayoutManager(glm);
Upvotes: 1