简体   繁体   English

如何在 Recycler-view 中添加分区

[英]How to add section divider in Recycler-view

Scenario : I am trying to add the section between items in the recycler view.场景:我正在尝试在回收站视图中添加项目之间的部分。 This divider is not with every element but it is based on the datasource.这个分隔符不是每个元素都有,而是基于数据源。 My Datasource has a divider property for that cell it means it is a divider cell and a divider of 2dp*100dp need to be shown in place of the normal cell data.我的数据源对该单元格有一个分隔符属性,这意味着它是一个分隔符单元格,需要显示一个2dp*100dp的分隔符来代替正常的单元格数据。

WorkDone : I tried to do that using two sibling inside the my recycler-view main cell-view which will be passed to the holder. WorkDone :我试图在我的回收站视图主单元格视图中使用两个兄弟来做到这一点,这将被传递给持有人。 In one sibling there is my main cell layout and in another one just the separator view and based on the datasource while binding I am changing the visibility of the each sibling.在一个兄弟姐妹中有我的主单元格布局,在另一个兄弟姐妹中只有分隔符视图,并且在绑定时基于数据源我正在更改每个兄弟姐妹的可见性。 But I am facing that while scrolling back and forth multiple separator and coming at random placed and keep on increasing while scrolling.但是我在来回滚动多个分隔符并随机放置并在滚动时继续增加时面临着这个问题。

Question :问题

  1. Is this is correct way to achieve desired result?这是达到预期结果的正确方法吗?
  2. What am i doing wrong ( fix for this?)我做错了什么(解决这个问题?)

Sample UI : As there is divider between Instagram sizes ans Facebook sizes示例 UI :因为 Instagram 尺寸和 Facebook 尺寸之间存在分隔线

图片

If you implement these scenario (having two types of holders) in a right way, i think it's the best way to achieve your goal.如果你以正确的方式实现这些场景(有两种类型的持有人),我认为这是实现你的目标的最佳方式。

After some more google targeted search able to find one solution:经过一些更多的谷歌有针对性的搜索能够找到一个解决方案:

Two view holder for different views.不同视图的两个视图持有者。

Most close working solution 最接近工作的解决方案

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

相关问题 将分隔器添加到领域回收器视图? - Add divider to realm recycler view? 如何从Recycler-View适配器接收活动中的点击事件 - How to receive click event in activity from a recycler-view adapter 单击行时的回收站视图数据绑定 - Recycler-view data binding on click of row 在Android中的Recycler-View上添加图像时,滚动视图无法正确滚动 - Scroll-view not scrolling properly when add images on Recycler-View in android Android回收站视图中的分隔线 - Divider in Android recycler view 如何在android中的项目下方的recycler-view中减少修复阴影效果 - how to reduce fix shadow effect in recycler-view below item in android 如何将可拆分数组列表添加到部分回收器视图适配器 - How to add parcelable arraylist to section recycler view adapter 如何在回收器视图中删除动画时隐藏分隔符 - How to hide divider when delete animation happens in recycler view Android多个水平回收站视图一起滚动 - Android multiple horizontal recycler-view scroll together 在活动中发送和添加回收者视图数据时遇到问题 - Getting a problem in sending and adding recycler-view data in an activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM