Using a GridView, is it possible to allow the item directly above and below all the visible items to remain in memory? (I have one column in my grid view)
I would like my adapter to prevent recycling for those items as long as they are direct neighbours to items that are currently visible.
My problem was that my GridView had some padding on both left and right side. This made the neighbouring items invisible/recycled "too fast".
Removing the padding resolved my issue.
Related
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
I want to achieve a specific pattern with a RecyclerView list by displaying a dynamic contact list based only on a single CardView.
The contact list can have several items in it. Like over 100. Every contact should be a single item and of course, all the area should be scrollable.
A solution would be to make a non-scrollabe ListView but the scroll would not be fluid as there are many items in the list.
Another solution would be to create a custom CardView item for the top, the middle and the bottom or even overlap all the CardView items with a negative margin.
I am wondering if there are some better solutions working with the RecyclerView?
I would try to use a nested recycler and intercept (steal) touch events with the child in the area it's in.
I have a listview and its rows have different heights.
When I scroll up, rows appear to move up or down erratically.
(I don't find the behavior when I scroll down)
I suspect its due to the fact
listView picks one of used rows
the row is placed on top of visible rows.
listView changes the row's height(here erratic movement)
but it's a guess.
I tried googling since this should be a common problem but couldn't find any.
In this case, setting the right item height did the trick :
How to set different heights for each row in a ListView?
Edit: oh, and make sure you recycle the items correctly :
ListView reusing views when ... I don't want it to
I would like to have last item of the listView aligned on the bottom.
In case there are 1 to several items on the list, there should be an empty space between last item and second to last item.
In case there are many items (they do not fit in the list, scroll is shown), the list should behave normally.
I tried to make it so that when list consists of some small hardcoded number (6) of items (or less), last item is separate view aligned to the bottom of the parent of the listView. When there are more items, I set visibility of this view to GONE and added same view to the listView. It was working fine, but not for all devices. Some fit 6 items, but others fit 7.
Is there any way to align last item to the bottom of the listView (so the listView has always the same height as its parent)?
Maybe the easiest way to implement this will be just to add your last element as footer using addFooterView
i want to display the listview's scroll item by item, means single item height is equal to listview height, so on listview there is only one item will display at a time, and after scrolling the listview, remaining item will display. But problem is that if i scroll listview, it scroll many items, but i need to scroll only by one item.
in-short listview scroll by many row at a time but i want only one row scroll at a time
please suggest me some tips or method :)
thank you
So if I understand you correctly, you want a 'pager', sort of like, you scroll page per page instead of inbetween every item, right?
I'm using a Horizontal Pager at the moment, it uses a GroupView and measures the scroll amount to snap to the next view in the pager. Perhaps you could write your own GroupView as well calculating the scroll Y values to snap to the next page..
It's not going to be easy, but it's the only way I can think of.
You could look up Horizontal Pager on google and look at the code, and implement it for vertical paging :)