Heterogeneous Layout with Staggered Layout- Recyclerview Android

Danish Amjad
AndroidPub
Published in
1 min readOct 10, 2018

--

Recently, I’m working in an application in which I need to implement the layout like above:

So, how gonna I achieved this all, I just play with the spanCount.

In this article I just show you the 3 items implementation rest you all can see my github repo.

First, you just need to define items like below code:

Now what I did next I set the span value in setSpanValue() function.

For Case Even & For Case Odd:

I just checked the list size is even / odd with the below function:

After all this, I just play in my adapter class, and play with the item height and width like below:

That’s it…Sharing the Knowledge is Caring :-)

Github Repo:

Thanks for reading this article. Be sure to clap to recommend this article if you found it helpful. It means a lot to me.

If you need any help then Join me on Twitter, Linkedin, Github, and Subscribe to my Youtube Channel.

--

--

Danish Amjad
AndroidPub

Senior Mobile Engineer (Android). Open Source Contributor, Technical Writer, ✉️ Dani.amjad12@gmail.com 🔗 https://danishamjad12.github.io