5

I have already read many question on SO and Google regarding Sticky headers in a recyclerview. However, most of them sticks the complete list item on top. I just want to stick part of my list item to top of recyclerview until the complete item is scrolled. I have gone through some libraries such as this one but still not able to figure out how to get it done. Any help is appreciated.

I want to stick the content which is highlighted in the red box until the complete list item (marked in green) is scrolled.

enter image description here

Ali_Waris
  • 1,944
  • 2
  • 28
  • 46
  • while setting adapter you can set scrollToPosition(item_position) – Arnold Brown Mar 01 '18 at 05:10
  • @ArnoldBrown Can you please explain what you meant by setting scrollToPosition()? Where to add this code and what is item_position? – Ali_Waris Mar 01 '18 at 05:27
  • Go through this article with an exact solution what you are looking for ref. link here : https://android.jlelse.eu/the-beauty-of-a-sticky-itemdecoration-db18171f5e26 – Sandeep Devhare Jun 28 '20 at 05:56

1 Answers1

2

So you want to stick just a part of your list item link this?
enter image description here

Check out this library
https://github.com/oubowu/PinnedSectionItemDecoration
Combine with this RecyclerView Adapter library:
https://github.com/CymChad/BaseRecyclerViewAdapterHelper

Tuấn Kiệt
  • 312
  • 3
  • 13
  • I am already having my adapter code written which scrolls the complete list item. I would be grateful if you could help me in using the same without using an external adapter library. – Ali_Waris Mar 01 '18 at 05:26
  • In the code sample they have used the header and assigned to it respective items. But, in my case, the items are getting inflated dynamically in onBindViewHolder method. How can I dynamically set items to a specific header? – Ali_Waris Mar 01 '18 at 05:48