All Projects → shuhart → StickyHeader

shuhart / StickyHeader

Licence: Apache-2.0 License
A simple lightweight sticky header ItemDecorator for RecyclerView

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to StickyHeader

Timeline
瀑布流式的时间轴
Stars: ✭ 2,028 (+1777.78%)
Mutual labels:  recyclerview, itemdecoration
TimelineView
A customizable and easy-to-use Timeline View library for Android. Works as a RecyclerView decorator (ItemDecoration)
Stars: ✭ 169 (+56.48%)
Mutual labels:  recyclerview, itemdecoration
ItemDecorations
A dividers library for RecyclerView which use GridLayoutManager or LinearLayoutManager,when the RecyclerView used GridLayoutManager that supports Cross-Column feature.一款RecyclerView的分割线库,支持LinearLayoutManager和GridLayoutManager,当使用GridLayoutManager时支持跨行特性
Stars: ✭ 42 (-61.11%)
Mutual labels:  recyclerview, itemdecoration
Flexibleadapter
Fast and versatile Adapter for RecyclerView which regroups several features into one library to considerably improve the user experience :-)
Stars: ✭ 3,482 (+3124.07%)
Mutual labels:  recyclerview, sticky-headers
Poweradapter
Adapter for RecyclerView(only 21KB).RecyclerView万能适配器(仅21KB)
Stars: ✭ 112 (+3.7%)
Mutual labels:  recyclerview, sticky-headers
Brv
Android上最强大的RecyclerView库
Stars: ✭ 345 (+219.44%)
Mutual labels:  recyclerview, sticky-headers
FlexItemDecoration
FlexItemDecoration, can customize the head, bottom, leftmost, rightmost dividing line, but also customize any one of the dividing lines and batch custom multiple dividing lines
Stars: ✭ 52 (-51.85%)
Mutual labels:  recyclerview, itemdecoration
Omegarecyclerview
Custom RecyclerView with additional functionality. Allow you add divider, itemSpace, emptyView, sticky header and some other features
Stars: ✭ 132 (+22.22%)
Mutual labels:  recyclerview, sticky-headers
SpacingItemDecoration
ItemDecoration for RecyclerView that allows you to set spacing between and around list items in flexible way.
Stars: ✭ 83 (-23.15%)
Mutual labels:  recyclerview, itemdecoration
codeKK-Android
http://p.codekk.com/
Stars: ✭ 29 (-73.15%)
Mutual labels:  recyclerview
UltimateRecyclerView
A RecyclerView(advanced and flexible version of ListView in Android) with refreshing,loading more,animation and many other features.
Stars: ✭ 7,238 (+6601.85%)
Mutual labels:  recyclerview
GenericAdapter
⛳️ Easy to use android databinding ready recyclerview adapter
Stars: ✭ 26 (-75.93%)
Mutual labels:  recyclerview
jubako
A small API to help display rich content in a RecyclerView such as a wall of carousels
Stars: ✭ 28 (-74.07%)
Mutual labels:  recyclerview
GenericRecyclerAdapter
Easiest way to use RecyclerView. Reduce boilerplate code! You don't need to write adapters for listing pages anymore!
Stars: ✭ 53 (-50.93%)
Mutual labels:  recyclerview
Android-Model-View-Presenter
No description or website provided.
Stars: ✭ 26 (-75.93%)
Mutual labels:  recyclerview
AndroidRecyclerViewWithLoadingEmptyAndRetry
recyclerview
Stars: ✭ 16 (-85.19%)
Mutual labels:  recyclerview
WinForm.UI
WinForm 皮肤,自定义控件
Stars: ✭ 100 (-7.41%)
Mutual labels:  recyclerview
RichEditor
基于RecyclerView实现的富文本编辑器,支持多样式,链接,引用,图片等功能
Stars: ✭ 70 (-35.19%)
Mutual labels:  recyclerview
movie-booking
An example for booking movie seat, combined of Android Data Binding, State Design Pattern and Multibinding + Autofactory. iOS version is: https://github.com/lizhiquan/MovieBooking
Stars: ✭ 80 (-25.93%)
Mutual labels:  recyclerview
LxAdapter
RecyclerView Adapter Library
Stars: ✭ 50 (-53.7%)
Mutual labels:  recyclerview

StickyHeader

The StickyHeader was created mainly because most popular libraries for sticky headers are too complicated or offer much more features than needed. Some of these libraries also break DiffUtils. For performance reason, a header view is created only once while view types and click listeners are not supported.

Also, by customizing this view via supplied adapter, a new sticky header will replace the previous one.

Sample

Usage

  1. Add mavenCentral() to repositories block in the gradle file.
  2. Add implementation 'com.github.shuhart:stickyheader:1.1.0 to the dependencies.
  3. Look into the sample for additional details on how to use and configure the library.

An adapter that extends StickyAdapter is necessary for the StickyHeaderItemDecorator that is used to create and bind sticky headers:

@Override
public int getHeaderPositionForItem(int itemPosition) {
    // Return a position of a header that represents an item at adapter position.
    // For the header itself return the same itemPosition.
}

@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder holder, int headerPosition) {
    // Update a header content here.
}

@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup parent) {
    // Create a ViewHolder for a header (called only once).
}

Then, attach it to the RecyclerView:

StickyHeaderItemDecorator decorator = new StickyHeaderItemDecorator(adapter);
decorator.attachToRecyclerView(recyclerView);

How it works

  • A ViewHolder is created by the adapter to reuse and bind every header.
  • A header view is drawn on top of the RecyclerView using onDrawOver() callback of ItemDecoration.

License

Copyright 2018 Bogdan Kornev.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].