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.
Related
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.
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.
I have RecyclerView with items that plays animations and I would like to start and stop playing those animations when item appears on and disappears from the screen.
I found addOnChildAttachStateChangeListener method of RecyclerView in official doc. But when I tried to use it Android Studio cant find such method.
Is there any other listener I can use ? Or should I set some kind of ScrollListener and check it there?
I have a listview where I take control of the focus. When I reach the last visible position and click down the listview does not scroll. However, if I touch and scroll the listview then try to navigate the listview using my custom focus control, it works.
My question is what state does android put a listview in when the user touch and scrolls it?
I don't know what the problem was, but changing the Activity to a ListActivity solved the issue.