Hi I want to display index at top of recyclerview it when scrollin to it
I tried
Recyclerview.scrolltoPosition(index)
Recyclerview.smoothscrollToPosition(index)
Layoutmanager.scrolltoPosition(index)
even used custom layoutManager and no change .
Related
I want to change the layout of the center item of the recycler view while scrolling.
For example - If we have a horizontal recycler view of images, I want to show text along with the image for the center item visible on the screen, and the rest of the items will only contain the image. While scrolling also I want such behavior. So implementing CustomScrollListener for recycler view is not helping.
Right now I am changing the viewType of the center item in the CustomScrollListener when it stops scrolling. It is working but I want such behavior while scrolling.
Context
I have a nested Recyclerview like the following sketch shows you:
In the drawing you can see a RecyclerView, which in turn holds one RecyclerView each as item.
Question
My question now is: How can I get the outer, parent Recyclerview scroll to a position of one of the child RecyclerViews. In the drawing I marked you Content pos 5 as my target position for example the Child RecyclerView 2.
What I already found out
One approach I've been thinking about was using scrollToPositionWithOffset(position, offset) on the parent RecyclerView, then just scroll to the position of the child RecyclerView 2 and then have the offset as the size of the list of items in the Child RecyclerView. But how can I get the size when the view isn't even inflated?
I would be very happy if one of you could give me some help that also ran into this problem of scrolling to a position of the child RecyclerView in such a nested Recyclerview.
I want to scroll a specific item to the top in RecyclerView.
Here is the code I am using,
rvTweets.smoothScrollToPosition(position);
or
linearLayoutManager.scrollToPositionWithOffset(postion,0);
Both the code work when RecycelerView has enough items to cover the complete height of the screen. Otherwise, it does not scroll the desired position to the top.
I made header and footer in my RecyclerView using typical solution with viewType in Adapter. It works fine, but I want to hide the footer if all RV items fit inside the screen, when nothing to scroll. Is there any way to know that all items will be displayed without scrolling and say to Adapter not to add footer in this case?
You can get scroll offset of recycler view with this code
recyclerView.computeVerticalScrollOffset();
Then you should check if scroll offset is more than your parent views heigh and do what you want ;)
What I want to achieve is that when the list is populated in recyclerview, every list item when scrolled up or down should be displayed as one item in the list only(covering whole of the space provided for the recyclerview). In other word, lets say that each list item should match the height and width of recyclerview. When the list is scrolled all the big listitems can be seen scolling but when scrolling ends only one view is displayed.
If still not clear, I just want a recyclerview to show only one item at a time and if we want to see other list items we have to scroll.
Similar to what a view pager but vertical in direction and should be using a recyclerview.