vinodh kumar
vinodh kumar

Reputation: 83

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. 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.

Screen shot here

Upvotes: 0

Views: 430

Answers (3)

AskNilesh
AskNilesh

Reputation: 69709

you can use StaggeredGridLayoutManager

private StaggeredGridLayoutManager gaggeredGridLayoutManager;
gaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, 1);
recyclerView.setLayoutManager(gaggeredGridLayoutManager);

for more information follow this link StaggeredGridLayoutManager

enter image description here

Upvotes: 0

Aditya Vyas-Lakhan
Aditya Vyas-Lakhan

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

Dhanumjay
Dhanumjay

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

Related Questions