百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

PinnedSectionItemDecoration

> 编程语言
开源

一个强大的 RecyclerView ItemDecoration, 支持常见的布局管理器。

2.1K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个强大的 RecyclerView ItemDecoration, 支持常见的布局管理器。

Pinned section header decoration for RecyclerView.

「中文版文档点这里」

(Please pay attention to a better project StickyItemDecoration)

A powerful pinned section header library. The realization of ideas comes from「pinned-section-item-decoration」. Please mark a star if you think it's helpful.(^∀^)

Function

  • Large pinned section header support vertical orientation of the LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager.
  • Small pinned section header support vertical orientation of the LinearLayoutManager and GridLayoutManager which its span count is 1.
  • Support the header of the click, double click and long press event.
  • Support the child view of the click, double click and long press event.
  • It can draw the separator line and support custom separator line style. (PS: Vertical staggeredgrid layout requires fixed height, can not be randomly changed to lead to item position switch, refer to「See line 89-108 of MainActivity」)

Screenshot

Extension library

BaseRecyclerViewAdapterHelper(It is highly recommended to use this adapter, which can greatly reduce the amount of work. The current demo is using v2.9.42.)

How to use?

To add a dependency using Gradle:

groovy
If using androidx
    compile 'com.oushangfeng:PinnedSectionItemDecoration:1.3.2-androidx'
otherwise
    compile 'com.oushangfeng:PinnedSectionItemDecoration:1.3.2'

Adapter needs to process the span count of header through the FullSpanUtil.

    @Override
    public void onAttachedToRecyclerView(RecyclerView recyclerView) {
        super.onAttachedToRecyclerView(recyclerView);
        FullSpanUtil.onAttachedToRecyclerView(recyclerView, this, StockEntity.StockInfo.TYPE_HEADER);
    }

    @Override
    public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
        super.onViewAttachedToWindow(holder);
        FullSpanUtil.onViewAttachedToWindow(holder, this, StockEntity.StockInfo.TYPE_HEADER);
    }

To achieve large pinned section header, RecyclerView only need to add a PinnedHeaderItemDecoration. Note that the top layer of the header where the layout can not be set marginTop.「See StockActivity」

…

To achieve small pinned section header is a little bit more complex, such as the layout A of the data .

…

This is a layout B with a small pinned section header.

…

The layout B add a header compare whit layout A,then RecyclerView only need to add a SmallPinnedHeaderItemDecoration. Note that the top layer of the header where the layout can not be set marginTop.「See SecondActivity」

…

License

Copyright 2016 oubowu

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.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javarecyclerviewstickyheader

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言