Gaps in between recyclerview items when view inside item is shown/hidden - android

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.

Related

Preload item in recycler view(recycler inside recycler)

I have a vertical recyclerview with multiples types like horizontal recycler inside.
My problem concern an item not visible (so not bind yet) at the start of the fragment (i.e maybe the item number 6 ou 7 of the list).
This item is an horizontal recycler view and when I first scroll to the bottom I have a lag when the item is binding...
I already optimzed my xml to have just 1 parent view
I already set fixed size to true
I already also setNestedScrollingEnabled(false)
😕
So, I tried to use pretech item count from this article (
https://medium.com/google-developers/recyclerview-prefetch-c2f269075710) but I don't see the difference. (maybe I don't implement it correctly)
I am asking if I can really bind this item (it's an horizontal recycler) when he is not visible...
I want to keep the main recycler and don't inflate manually a linear layout because I have a lot of view types ( I tried but the solution was pretty ugly).
Thanks in avance

Android RecyclerView scrolls to top when child element is expanded/collapsed

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).

addHeaderView or addFooterView not available in Recycler VIew

I was trying to design my screen as of same in Swiggy App. First, it has horizontal recycler or horizontal scroll view.
Second, it has tab bar which will stick on the top once we will scroll up. Third, it has a vertical recycler view or maybe listView showing restaurants.
So, if we have vertical listView, it's very easy to stick that tab bar(view, the second thing on screen) on the top.
You can see an example here: https://dzone.com/articles/creating-a-listview-parallax-effect-with-a-sticky
But in case of RecyclerView, it doesn't have any direct method addHeaderView. So how do we implement this with RecyclerView.
Use getItemViewType method and create three view holders for first, middle and last items.
RecyclerView with multiple view type

Android list view inside a scroll view auto scroll issue

I have an android layout setup where I have a ScrollView with some elements and inside that I have a ListView. I am using StackOverflow's answer Android list view inside a scroll view for achieving this feature and it's working fine. My ListView is below some elements like TextView, ImageView. Problem is that when the page is presented ListView get scrolled automatically so that first item in listView is at the top (ie whole scrollview gets scrolled to present listview first item). How can I avoid this auto scrolling?
Add android:descendantFocusability="blocksDescendants" to child of SrollView (and parent of ListView)

Android ListView stops scrolling when inside a Scroll View

Why is it when I insert a list view into a scrollview, the list view stops scrolling.
The Scroll View scrolls normally, but the list view seems as if it is frozem
Well it seems that you must not place a list view inside a scroll view, because the system will not know which control to scroll!
There is no need to add listview in scrollview since scrolling is a default property for
ListView. That is all.
Please go through the Android documentation before design any of the UI.

Categories

Resources