简体   繁体   English

将项目粘贴到 recyclerview 的顶部

[英]Stick an item to top of recyclerview

I have already read many question on SO and Google regarding Sticky headers in a recyclerview.我已经在 SO 和 Google 上阅读了许多关于回收站视图中粘性标头的问题。 However, most of them sticks the complete list item on top.但是,它们中的大多数都将完整的列表项放在最上面。 I just want to stick part of my list item to top of recyclerview until the complete item is scrolled.我只想将我的列表项的一部分粘贴到 recyclerview 的顶部,直到滚动完整项。 I have gone through some libraries such as this one but still not able to figure out how to get it done.我已经浏览了一些库,例如这个库,但仍然无法弄清楚如何完成它。 Any help is appreciated.任何帮助表示赞赏。

I want to stick the content which is highlighted in the red box until the complete list item (marked in green) is scrolled.我想粘贴红色框中突出显示的内容,直到滚动完整的列表项(标记为绿色)。

在此处输入图片说明

So you want to stick just a part of your list item link this? 所以你想只列出你的列表项链接的一部分吗?
在此输入图像描述

Check out this library 看看这个图书馆
https://github.com/oubowu/PinnedSectionItemDecoration https://github.com/oubowu/PinnedSectionItemDecoration
Combine with this RecyclerView Adapter library: 与此RecyclerView适配器库结合使用:
https://github.com/CymChad/BaseRecyclerViewAdapterHelper https://github.com/CymChad/BaseRecyclerViewAdapterHelper

Try this!! 尝试这个!!

This will make the selected(item position) item to stick on top view 这将使所选(项目位置)项目粘在顶视图上

recyclerView.setAdapter(adapter);
recyclerView.scrollToPosition(item_posotion);
adapter.notifyDataSetChanged();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM