I have a RecyclerView in bottom sheet. Every time I close and re-open the bottom sheet.
I would like the last RecyclerView scroll position to be ignored
(it should always display with item 0 as the top fully visible item as
if it was opened for the first time).
The data is always the same so I don’t need to reload it.
Is there a better option to accomplish this than scrollToPosition(0)?
you can achieve your purpose by calling
RecyclerView.smoothScrollToPosition(0);
or
RecyclerView.getLayoutManager().scrollToPosition(0) ;
or as you said
RecyclerView.scrollToPosition(0);
Related
I have a recycleview that I like to go past the last element when I scroll up. The reason I need to do this is that I have a floating button that if I don't go past the last item, the floating button covers the right part of the last item. I have seen this done in apps such as WhatsApp (see screenshot).
My approach has been to add two empty items to the end of my list and then set visibility of views based on if the items are empty or not. I feel this is more a hack and I was wondering if there is a better way around this.
Below is a screen shot from WhatsApp where at the end of the list, the list scrolls further.
Thanks in advance
There is not need to add two blank items to recyclerview. It may introduce bugs as well while adding new items to the recyclerview. You just need to provide paddingBottom to the recyclerview equal to the height of floating action button and set clipToPadding = false to the recyclerview.
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.
I want to be able to scroll a RecyclerView behind a keyboard. The issue is that if I have say more than 5 items in the RecyclerView.Adapter, and assume that each item might have a height of say 100dp. I want to be able to scroll the RecyclerView down with the keyboard still up and be able to scroll down to be able to see the first item in the RecyclerView.
In iOS you can set something called a contentInset on a NSTableView and that gives you extra scrolling space below the list. I am looking for something similar for the RecyclerView so far, there isn't much to go on.
INITIAL STARTING POINT
WHAT HAPPENS (Can't scroll down anymore)
WHAT I WANT (be able to scroll down)
I have tried RecyclerView.smoothScrollToPosition(int position), but it's not what I want. It scrolls to a position so that the child get into the viewport; it can either appear at the beginning or the end. Moreover, if the view is already in the viewport, it won't do anything!
What I need to do is to scroll to a position and make it appear at very beginning of RecyclerView so as to arouse user's attention. How can I do with it?
You can use mRecyclerView.scrollToPosition(Position); to display the list item at top. However it will go to the specified position very quickly without any scrolling effect.
When I click on a row in a vertical list RecyclerView, I call remove the item from the backing list, and call adapter.notifyItemRemoved(position). When position == 0 the move animation is called, otherwise remove animation is called.
In both cases, after that animation is called, an add animation is called for all other visible items on the screen. This makes the remove animation look bad, because all other items flash while the remove animation is being run.
Anyone know what could be causing that?
That does not make sense.
If you remove item at 0 (assuming it is visible and top item), there would be a "remove" for that item and "move" animation for all other visible views + one more (the new item to fill the new space but it comes with a move animation from below the list).
Can you post some code?
I was using TwoWayView (github.com/lucasr/twoway-view). I've had too much trouble with it, and removing it seems to have fixed any trouble I was having, including this issue.
Filed an issue with the project on Github here.