[英]How can I show Recyclerview cardview with horizontal views like adds after every four items in android
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.
但是我需要使用recyclerview卡视图以网格视图的方式在每四个项目之后显示一个水平项目(如添加)。 adds means I am not using google add mob.
添加意味着我不使用google add mob。 I am just show an item like a add in horizontal manner.
我只是以水平方式显示类似添加项的项目。 I am confused.
我很困惑。 any one can help me.
任何人都可以帮助我。
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);
You can use Recyclerview or Gridview with sticky headers 您可以将Recyclerview或Gridview与粘性标头一起使用
<dependency>
<groupId>com.tonicartos</groupId>
<artifactId>stickygridheaders</artifactId>
<version>1.0.1</version>
</dependency>
https://github.com/DWorkS/AStickyHeader https://github.com/DWorkS/AStickyHeader
http://tonicartos.github.io/StickyGridHeaders/ http://tonicartos.github.io/StickyGridHeaders/
https://github.com/ShamylZakariya/StickyHeaders https://github.com/ShamylZakariya/StickyHeaders
https://github.com/timehop/sticky-headers-recyclerview https://github.com/timehop/sticky-headers-recyclerview
you can use StaggeredGridLayoutManager 您可以使用StaggeredGridLayoutManager
private StaggeredGridLayoutManager gaggeredGridLayoutManager;
gaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, 1);
recyclerView.setLayoutManager(gaggeredGridLayoutManager);
for more information follow this link StaggeredGridLayoutManager 有关更多信息,请单击此链接StaggeredGridLayoutManager
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.