I am creating a custom scroll inside RecyclerView and I did most of the work already but now I came to hopefully one of the last problems.
On scrolling, I am expanding/collapsing rows as they move up or down. It works fine until I reach the bottom of the list. Two items remain in their normal state because I can no longer scroll down and therefore they will not expand.
My question is, how can I scroll under the recyclerView when I reach the bottom? Do I need to implement onTouch listener and do the work from there? Or is there something in RecyclerView that can help me create the underscroll?
You should be able to expand them in onOverScrolled, as that will be called at the correct time to trigger their expansion.
Related
In our fire tv app, we are using a nested recyclerview where every vertical item have a horizontal row as a child item like playstore design.
Scrolling with dpad working fine normally but when i hold the right key for few seconds, item start scrolling very fast because it gets many events & within few second focus goes to the next random row even current row has items to scroll. So this whole problem happening in horizontal scroll(child recyclerview). I have already tried many solutions like this, this, this.
Also tried the custom layout manager, custom focus layout & other approach like slowing down the recyclerview scroll etc approach but all not working.
As far as I know, this happens at the moment when the last item is in focus, and the next item is not visible, that is, the ViewHolder has not updated the data of the first cell, so it is not clear which element to show next as if the list has ended.
You need to make sure that at least the edge of the next element is always visible on the screen.
Maybe you should play with the cell size or divider.
Edit:
The secret is to use the leanback library. It isn't lost focus!
Your gradle:
// Leanback support
def leanback_version = "1.2.0-alpha01"
implementation("androidx.leanback:leanback:$leanback_version")
Change in the layout from RecyclerView to HorizontalGridView (VerticalGridView)
Change in the Fragment import from RecyclerView.widget.GridLayoutManager to androidx.leanback.widget.GridLayoutManager
It works very fast for me and the focus no longer jumps.
Here a good article with animations but little outdated
I want to be able to scroll a RecyclerView behind a keyboard. The issue is that if I have say more than 5 items in the RecyclerView.Adapter, and assume that each item might have a height of say 100dp. I want to be able to scroll the RecyclerView down with the keyboard still up and be able to scroll down to be able to see the first item in the RecyclerView.
In iOS you can set something called a contentInset on a NSTableView and that gives you extra scrolling space below the list. I am looking for something similar for the RecyclerView so far, there isn't much to go on.
INITIAL STARTING POINT
WHAT HAPPENS (Can't scroll down anymore)
WHAT I WANT (be able to scroll down)
I need a component that works like the picture below but I'm having trouble coming up with some kind of decent solution that works.
I want the list to have a center locked selection but being scrollable with the d-pad. This is for an application running on a TV so no need for touch scroll. So when pressing down on the remote d-pad the list will scroll and a new item will size up and the current selected one will size down and the new selection will still be in the middle.
I've tried doing this using a ListView that I extended and programmatically scrolling when pressing down or up. On scroll finished I called notifyDatasetChanged() on the ListView for re-inflating of the childs and in the ListViews adapters getView() I made the animation of the view located at the current selected position.
This is not optimal since I need to call notifyDatasetChanged(), which re-inflates all visible views, for the animation to apply. The UI becomes laggy when doing this and scrolling fast. It's also not possible to make som kind of compress animation when current selected item goes out of selection. There is also some trouble with the end items (read views) such the first or last in the list when doing animation of them, the may sometimes go out of screen.
I think that his must have been done before and maybe I'm missing it when searching for an answer.
Have anyone done something similar or do you have some suggestions of how this can be achieved? Maybe I'm just starting of with the wrong component here..
Regards,
Kristoffer
I have an HorizontalScrollView in my design, which I populate with a variable number of items. The problem I have is that sometimes I populate it with many items, so the ScrollView shows scroll bars. That's OK, but I would like to check this situation and show a Previous and Next buttons in this case.
How can I do this?
I don't think ScrollView has a scroll listener. Synchronise ScrollView scroll positions - android might help you for creating a custom one.
Im having trouble with my UI.
It contains a ListView , with ViewPagers as List Items.
The problem is that the horizontal scrolls seem to get interrupted by the ListView (catching vertical scrolls).
What i want to achieve is that no matter what happens, the horizontal scrolls finish all the time. Right now they stop half way sometime.
this is probably a common problem, but i havent found a solution yet.
I've tried to intercept horizontal scrolls on the the listview, but although I can intercept, it still causes the swipe to stop.
can anyone point me in the right direction ?
ViewPagers are not compatible with ListViews.
Sorry.
ViewPager inside ListView