So, I've got this structure in my app:
RecyclerView
|
--> View
--> CustomListView
--> CustomListView
After all views are loaded in the adapters (RecyclerViewAdapter and the ListViewAdapters) my scroll position is about on the middle of the page - but my desired and initial scroll position should be on top.
So, I know I can change the scroll position through the recycler view, but the problem is: when should I do it? I don't have any callback from the adapters, so I don't know when all the views are loaded..
Any ideas?
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.
I am using recycler view with linear layout manager, based on some logic I am hiding/showing a view inside recycler view item.
Issue Problem occurs when I scroll, I can see some gaps in between recycler view item, which are random when scroll. If I hide the view always , then there is no issue, but I need to show and hide based on some logic and when implemented the gaps are coming as well.
Assumption One thing I am sure of is that the issue is there because of hiding/showing a view.
I have a list of elements in a recycler view that are generated dynamically using data binding. Each element has a bottom view that is initially set to View.GONE, however once a user clicks the element and the view is expanded, the recycler view automatically scrolls back to the top of the list. Conversely, if the view is expanded and then clicked again to collapse, the recycler view scrolls to the top of the list again. I have tried keeping track of the ID's of the elements for the adapter (again using data binding), setting focus to the child element when they expand or collapse, and using binding adapters to animate the expand/collapse itself.
My suspicion is that the adapter in the recycler view is receiving a onNotifyDataChanged() alert when the height of one of the child changes, rendering an additional view (still inside one of the children though, not a separate child in the list), and automatically scrolls to the top. Is there a way to override this? Does anyone know what else might be causing the list to snap to the top when one of the elements is clicked -> expanded/collapsed?
So I found the solution to my issue in case someone encounters something similar. I actually ended up finding this answer: RecyclerView notifyDataSetChanged scrolls to top position
and the second solution involving the staggered layout manager was the route I went with, since I want to be able to wrap the content. My suspicions were correct that it had to do with the changing height of the elements in the recycler view. The expandable item's parent wrapped content, so the recycler view was forced to recalculate the size of the item once the expandable portion appeared/disappeared (at least that's what I got out of it).
So to be clear, I can solve this with a header view and trickiness, but I'd rather not.
I'd like to have a set of tabs (which also contains some profile information) above a view pager, which could have multiple pages, where each page has a list view. I'd like when you start scrolling initially, that the above tab / profile view will move with the list view (so if you try scrolling the list view, the area above scrolls up) and once the listview is scrolled down until it is at the first item, that the above view starts to scroll back into view.
This is not solveable with a header view, as far as I can tell, without stuffing this profile / tab view into the header of every list view the view pager holds, and to keep them in sync (which just sounds silly).
I feel there's a way I can make use of onInterceptTouchEvent with a custom layout / scrollview of sorts, any tips on doing this?
My application need to scroll up(means scroll up to top of the screen) the selected item in the scroll view using getTop() method. Is it possible? Then how to do it?
Thanks.