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.
Related
I am building an android app with two recyclerviews, one with horizontal LinearLayoutManager and the other one with GridLayoutManager.
I want to allow the items recyclerviews to be dragged and dropped over a trash icon outside of the recyclerviews, obviously to delete the dragged item.
What I have done is:
Apply android:clipChildren in the parent of the two recyclerviews
Apply android:clipToPadding in the recyclerviews
This works perfectly in recyclerview with LinearLayoutManager. I can drag an item and drop it over an icon that is outside of the recylcerview.
I also works in the recyclerview with GridLayoutManager, but with a side effect. When I scroll in the grid recyclerview the scrolled items come out of the recyclerview.
At the ende of this GIF you can see the scrolling issue
So, Is there any way to allow dragging a recyclerview item outside of the recyclerview boundaries but preventing items comeout when scrolling?
Lots of thanks for your help and suggestions in advance
I tried putting the recyclerview with LinearLayoutManager on top of the recyclerview with GridLayoutManager, to hide the items which came out of the boundaries, but this make a strange behaivour when I drag an item, because the items are there yet, even they are hidden. I could make a GIF if needed
My last option is putting the trash icon inside of the recyclerview, as a header that appears when dragging an item, but I would prefer not do it that way
Finally what I have learnt is that you have two main options when face a drag and drop problem:
Easy way: Using the Android helper ItemTouchHelper
Hard way: Not using the helper and type all the code, using startDragAndDrop()
A scenario like this only can be solved by the hard way.
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.
I need to implement list view that must show selected item in the center of list view.
Is it possible?
The problem is that list view forbid scrolling before top item and after last item.
The only workaround here I found is to add several dummy header and bottom items and use setSelectionFromTop() method for right positioning.
Is there any other better way?
Thanks
You could use a circular ListView Check this thread on how to implement it
and use smoothScrollToPosition to bring your particular view to the center.
You shouldn't need to add multiple dummy list items. Just extend your Adapter and use a single blank dummy list item that you can programmatically adjust the size of based on the screen resolution of the device.
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 :)
I have a list of about 100 items. In each list item I need a framelayout with 2 relative layouts. When a button called "Flip" is clicked then one relative layout will flip out and the other relative layout will flip in. And each item has full width of the screen. So, I need to show the item in a horizontal scroll view. Now, I want to keep at most 3 items every moment. When user scrolls to the first item then we have to update the 3 items. The first item will be the 2nd item. And we have to add another item at the front. In this way we have to update the items when user scrolls to the last item. I have tried many ways. I have used Gallery for the horizontal scroll view. And used the onItemSelected method. But, if I scroll the Gallery fast then it crashes. So, please someone help me to implement the 3 items idea.
It sounds like you need a ListView. Is there a reason you are trying to reinvent it?
Also don't you mean a vertical scroll view? Why are using a horizontal?