Twowayview automatically adds padding when scrolling

I am using Twowayview in one of my projects. This is an extension of the Recyclerview android library. (Having features like vertical horizontal checkerboard, stretched grid and lists). Sometimes elements in the form of a grid disappear when scrolling (i.e., they automatically add padding each time we scroll and move all the elements to the side we scroll). This is random behavior that does not occur every time.

Watch this video, Recyclerview Scrolling Problem

See below for more information about this issue.

Problem filling # 140

This autocomplete problem occurs when we add or remove an adapter with new elements.

Please find the widget I used below with attributes

<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" /> 

I found some solutions, such as strip removal from Twowayview, CliptoPadding, etc. But none of them work for me. I am using Recyclerview version 21.0.0. Anyone facing this problem? How to solve this problem?

+6
source share
2 answers

I rewrite the answer Ish

First of all, you should use the code of the TwoWay-View library, not jar.

  • Open the library layout folder.
  • View package org.lucasr.twowayview.widget
  • Public class BaseLayoutManager
  • Go to line No. 362
  • You will find the code as

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

replace this line with this

if (anchorItemPosition> 0 && refreshingLanes &! restoringLanes) {The above BaseLayoutManager class works for me as a solution to the above problems.

Hope this helps you all TwoWay-View users.

+5
source

You tried to add a custom onScrollListener to fix it when its state (). getTargetScrollPosition () maybe out of range

0
source

Source: https://habr.com/ru/post/982261/


All Articles