【问题标题】:Twowayview automatically add padding when scrollingTwowayview 滚动时自动添加填充
【发布时间】:2017-08-11 15:14:45
【问题描述】:

我在我的一个项目中使用Twowayview。这是 androids Recyclerview 库的扩展。 (具有垂直水平交错、可跨网格和列表视图等功能)。有时,gridview 中的项目在滚动时会消失(即,每次滚动时它都会自动添加填充,并且所有项目都滚动到我们滚动的一侧)。这是一种随机行为,并非每次都经历过。

观看此视频,Recyclerview scroll issue

请在下面的此链接上找到有关此问题的其他参考,

Padding problem #140

这种自动填充问题主要发生在我们添加或删除带有新项目的适配器时。

请在下面找到我使用的带有属性的小部件

<org.lucasr.twowayview.TwoWayView
android:id="@+id/spannable_grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animationCache="false"
android:scrollbarAlwaysDrawHorizontalTrack="false"
android:scrollbarSize="0px"
android:scrollbars="none"
android:scrollingCache="false"
app:layoutManager="SpannableGridLayoutManager"
app:numColumn="6"
app:numRow="6" />

我找到了一些解决方案,例如从 Twowayview、CliptoPadding 等中删除填充。但这些都不适合我。我正在使用 Recyclerview 21.0.0 版。有人遇到这个问题吗?如何解决这个问题?

【问题讨论】:

标签: android android-recyclerview


【解决方案1】:

我正在通过Ish转发答案

首先你必须使用 TwoWay-View 库的代码而不是 jar。

  1. 打开库的布局文件夹。
  2. 浏览包 org.lucasr.twowayview.widget
  3. 打开 BaseLayoutManager 类
  4. 跳转到第 1 行。 362
  5. 你会发现代码为

if (anchorItemPosition > 0 && (refreshingLanes || !restoringLanes)) {

用这一行替换这一行

if (anchorItemPosition > 0 && refreshLanes && !restoringLanes) { BaseLayoutManager 类的上述更改对我来说是上述问题的解决方案。

希望这将对所有 TwoWay-View 用户有所帮助。

【讨论】:

  • 此更改合并到原始项目的一个分支中。通过mrolcsi 或他的commit 查看分叉。使用这个 fork 而不是原来的,你可以编译并获得一个带有修复的 jar,而不是管理你自己项目中的所有源代码。
【解决方案2】:

您是否尝试添加自定义 onScrollListener 以在其 State().getTargetScrollPosition() 可能超出预期范围时进行更正?

【讨论】:

  • 无法回答。为问题添加评论。
  • 没有足够的代表来做这件事。
猜你喜欢
  • 1970-01-01
  • 2020-11-20
  • 1970-01-01
  • 1970-01-01
  • 2016-11-21
  • 2017-02-22
  • 2014-05-11
  • 2022-08-17
  • 1970-01-01
相关资源
最近更新 更多