I've updated my RecyclerView version to 26.0.1 and I have pagination implemented with RecyclerView, so when I reach bottom of the list I see ProgressBar and load more data to display, then notify inserted indexes
So with new 26.0.1 RecyclerView version there's inertia saved from scrolling. So when I swipe down fast and reach bottom I see ProgressBar, but after new data inserted RecyclerView keeps scrolling down
I know that's it inertia because if I swipe slowly, it doesn't scroll down after new data being inserted
Question: how to disable this inertia swiping?
P.S. My RecyclerView is inside NestedScrollView
Sorry for late response, but I faced with the same issue.
I had a NestedScrollView containing multiple items including RecyclerView.
I noticed that when LOADING state is shown, everything scrolls without any inertia, but once I make recyclerView visible, inertia appears. That code helped me:
recyclerView.isNestedScrollingEnabled = false
It helped for androidX RecylerView widget.
Ran into the same issue, a RecyclerView with infinite scrolling on API 26. Solved it by just adding this code to the overriden onScrolled event I was already using to load subsequent pages of data. I placed it after the super.onScrolled() call and before my infinite page loading trigger.
if (!recyclerView.canScrollVertically(1)) {
recyclerView.stopScroll();
}
This detects whether the RecyclerView can no longer scroll downwards (1 for down, -1 for up), and uses the built-in method to halt scrolling.
Related
I am building an android app with two recyclerviews, one with horizontal LinearLayoutManager and the other one with GridLayoutManager.
I want to allow the items recyclerviews to be dragged and dropped over a trash icon outside of the recyclerviews, obviously to delete the dragged item.
What I have done is:
Apply android:clipChildren in the parent of the two recyclerviews
Apply android:clipToPadding in the recyclerviews
This works perfectly in recyclerview with LinearLayoutManager. I can drag an item and drop it over an icon that is outside of the recylcerview.
I also works in the recyclerview with GridLayoutManager, but with a side effect. When I scroll in the grid recyclerview the scrolled items come out of the recyclerview.
At the ende of this GIF you can see the scrolling issue
So, Is there any way to allow dragging a recyclerview item outside of the recyclerview boundaries but preventing items comeout when scrolling?
Lots of thanks for your help and suggestions in advance
I tried putting the recyclerview with LinearLayoutManager on top of the recyclerview with GridLayoutManager, to hide the items which came out of the boundaries, but this make a strange behaivour when I drag an item, because the items are there yet, even they are hidden. I could make a GIF if needed
My last option is putting the trash icon inside of the recyclerview, as a header that appears when dragging an item, but I would prefer not do it that way
Finally what I have learnt is that you have two main options when face a drag and drop problem:
Easy way: Using the Android helper ItemTouchHelper
Hard way: Not using the helper and type all the code, using startDragAndDrop()
A scenario like this only can be solved by the hard way.
I have a ViewPager2 of vertical orientation with each item consisting of Recyclerview. Sometime on fast scrolling, the content of the recylcerview is not scrolled rather page change is triggered on ViewPager2.
When this issue occurs, I am using NestedScrollableHost provided by Android Developer site doesn't get a callback inside onInterceptTouchEvent method.
Please suggest.
I have to edit a ListView so that the autoscroll stop when I scroll up and restart when I scroll completely down as it works in Android Studio's window Logcat for example. How can I implement it?
The ListView is set with android: transcriptMode = "alwaysScroll".
implement OnScrollListener and look on the firstVisibleItem. Store it somewhere, then when onScroll is called again compare firstVisibleItem with what you got stored. If it's greater => The user is scrolling down otherwise the user is scrolling up.
I am creating a custom scroll inside RecyclerView and I did most of the work already but now I came to hopefully one of the last problems.
On scrolling, I am expanding/collapsing rows as they move up or down. It works fine until I reach the bottom of the list. Two items remain in their normal state because I can no longer scroll down and therefore they will not expand.
My question is, how can I scroll under the recyclerView when I reach the bottom? Do I need to implement onTouch listener and do the work from there? Or is there something in RecyclerView that can help me create the underscroll?
You should be able to expand them in onOverScrolled, as that will be called at the correct time to trigger their expansion.
Simple question - how to disable recyclerview scrolling while swiping its item? I created OnTouchListener inside recyclerView item view holder, but it catches swipe events only if user makes straight horizontal line. Otherwise recycler list is scrolling. Any ideas?
I am not using ItemTouchHelper because it doesnt quite do what I want. I solved this by checking the source to it and finding the call to:
getParent().requestDisallowInterceptTouchEvent(true)
Call that when you determine the user has started swiping (i.e., moved more than a few pixels). Then don't forget it to call it again with false when the swipe is done.
I'm facing the opposite problem. If you are using the ItemTouchHelper, do this
mItemTouchHelper.startSwipe(myViewHolder);
This would force the swipe instead of the scroll.