Add alphabetical sticky headers to a contacts list in an Android app so the current letter stays visible while scrolling.
Display a categorized product list with date or category headers that stay pinned at the top as users scroll through.
Build a chat log view with sticky date separators that stay visible as the user scrolls through message history.
Handle taps on stuck section headers to trigger collapse or expand behavior for that section.
Headers are drawn directly on canvas, not in the view hierarchy, async image loading in headers will cause rendering problems.
sticky-headers-recyclerview is an Android library that adds section headers to scrollable lists built with RecyclerView. When a user scrolls through a categorized list such as contacts grouped alphabetically or items grouped by date, the current section header sticks at the top of the screen until the next section arrives and replaces it. The library works as a decorator, meaning you add it to an existing RecyclerView without restructuring your existing code. Setup involves three classes. The adapter interface adds three methods to whatever adapter you already have: one to return a header ID for each list item, and two to create and populate the header view. The decoration class handles the actual rendering and requires no extra configuration beyond being attached to the RecyclerView. A third class handles click events on the stuck header. One thing to be aware of: the header views are drawn directly onto the canvas rather than being added to the view hierarchy. This means touch states such as highlight on press do not work on them, and loading images into header views asynchronously may cause problems. Header views are also not recycled, which the project acknowledges as a known limitation. Item animators may not interact cleanly with the decoration. The library supports both vertical and horizontal scrolling lists and requires Android API level 11 or above. When your data changes, you must manually call invalidateHeaders on the decoration to keep the headers in sync, since the decoration is not aware of the adapter directly. The repository is marked as unmaintained. The last release, version 0.4.3, was published in December 2015. The project credited Emil Sjolander's StickyListHeaders as inspiration for the original concept.
← timehop on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.