Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twowayview automatically add padding when scrolling

I am using Twowayview in one of my projects. Which is an extension of androids Recyclerview library. (Having features like vertical horizontal staggered, spannable grid and listviews).Sometimes the items in the gridview disappears when scrolling (ie, It automatically adding padding each time it scrolls and atlast all items scroll to the side we scrolled). It was a random behavior not experiencing every time.

Watch this video, Recyclerview scroll issue

Please find additional reference about this issue on this link below,

Padding problem #140

This auto padding issue mostly occur when we add or remove the adapter with new items.

Please find the widget i have used below with the 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 like remove the padding from Twowayview, CliptoPadding , etc. But none of these working for me. I am using Recyclerview version 21.0.0. Anybody experiencing this issue ?. How to solve this issue ?

like image 758
Sujith Avatar asked Feb 10 '15 12:02

Sujith


1 Answers

I'm reposting the answer by Ish

First of all keep you must use code of TwoWay-View library not jar.

  1. Open layout folder of library.
  2. Browse the package org.lucasr.twowayview.widget
  3. Open BaseLayoutManager class
  4. Jump to Line no. 362
  5. You will found code as

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

replace this line by this one

if (anchorItemPosition > 0 && refreshingLanes && !restoringLanes) { Above change in BaseLayoutManager class work for me as a solution to above mentioned issues.

Hope this will help you all TwoWay-View users.

like image 54
lal Avatar answered Nov 14 '22 16:11

lal