142
支持粘性Item的RecyclerView布局管理器
source link: https://juejin.im/post/5a25f82d51882531ea651f31
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
支持粘性Item的RecyclerView布局管理器
2017年12月05日 02:18
· 阅读 3110
很多 App 都被设计了分组列表有粘性条目的效果,而现在我们开发安卓,基本都用上了RecyclerView,这里介绍的这个开源项目就是在RecyclerView
上实现了这个效果,让我们看下效果图:
Image | Image | Image |
---|---|---|
StickyLayoutManager完全开源 Github
首先Adapter
需要实现StickyHeaders
接口并实现方法
class RecyclerView.Adapter implements StickyHeaders {
public boolean isStickyHeader(int position) {
// Implement this method
}
}
复制代码
然后设置相应的布局管理器
RecyclerView.setLayoutManager(new StickyHeaders...xxx...LayoutManager<RecyclerView.Adapter & StickyHeaders>());
复制代码
默认实现了StickyHeadersLinearLayoutManager
、StickyHeadersGridLayoutManager
、StickyHeadersStaggeredGridLayoutManager
.
本开源库并非由我开发,我只是基于作者Doist开发的这个开源项目整理而来,作者只实现了StickyHeadersLinearLayoutManager
。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK