ShamylZakariya / StickyHeaders

Adapter and LayoutManager for Android RecyclerView which enables sticky header positioning.
MIT License
1.4k stars 185 forks source link

Question on the items view and header position #80

Closed iad24 closed 6 years ago

iad24 commented 6 years ago

Just want to clarify something on position of the items. The header part also take the position right? Like below? I need the position for scrollToPosition function.

Section 1 -> 0 (position in the recyclerview) Item 1 -> 1 Item 2 -> 2 Section 2 -> 3 Item 1 -> 4 Item 2 -> 5

Cos if I want to show the Section 2 in the top of the recycler. But it seems its not working properly; especially when the recyclerview gets too long.

tulioccalazans commented 6 years ago

Hi. Check if these positions is really correct. Normally the footer must be taken in consideration to redirect to correct position.

iad24 commented 6 years ago

i dont use the footer. so i return false for doesSectionHaveFooter. So footers dont count here

iad24 commented 6 years ago

I have fixed my issue. Above im using my own positions; the right way is to use the adapter positions. like

recyclerView.scrollToPosition(adapter.getAdapterPositionForSectionHeader(sectionIndex)) recyclerView.scrollToPosition(getAdapterPositionForSectionItem(sectionIndex, itemIndex))