RecyclerView settle item with Decelerate Interpolator once scroll finishes - android

I want to animate the RecyclerView scrolling. I don't want to animate adding or removal of items but rather animate items which are on screen, i.e visible items. What I want is, item settle down smoothly when scrolling is about to finish. I am not sure what approach should I take or how this can be done. I have tried following till now
Using RecyclerView.OnScrollListener, when I get onScrolled callback, I find visible items & animate them upside or downside based on scroll direction. But this approach is no-where near to perfect & many times when scrolling fast, some visible views are null so animation doesn't apply on them & it looks weird.
Tried to animate visible items when I receive SCROLL_STATE_IDLE. But there's noticeable delay for a fraction of second when scrolling is finished & then items animate. It doesn't look natural
Tried to figure out when RecyclerView scrolling is "about to" finish so I can start animation to mimic continuity of animation with scrolling. But didn't get success in identifying reliably that scrolling is about to finish.
Instead of above a little complex ways that doen't work the way I need, I wonder if there is any other way like creating custom LayoutManagerwhere I can override the each item scrolling so that it settle to it's aimed position smoothly?
Edit: Here's something very close to what I wanted

Related

Be able to scroll RecyclerView behind Keyboard

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)

Center aligned selection with animation in ListView (?)

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

How to create an infinite carousel horizontal scroll bar in android?

In my android app, I have a horizontal scroll bar, and I can scroll all the way to the left and right. Go too far and you can't scroll anymore.
How can I change it that, you can keep scrolling left or right for as long as you want. Basically when u see the last thing in the horizontal scroll, then if you keep scrolling, you see the first item, and it loops like this. Similarly if you scroll to the left after seeing the first item, you see the last item.
Is this possible to do in android?
Thanks

Determine if the list view is about to stop scrolling?

I need to do some animations in a listview after it is flinged and is about to stop.I have a listview which is going to be of a fixed height(well dont ask me why), and whenever the scroll stops , it should have three elements visible. What i do now is detect when the list reaches SCROLL_STATE_IDLE and if i have two elements visible at that time, i use smoothScrollToPosition and reach a state of 3 items visible and it works fine, but what i would like to do is detect when the scroll is about to stop and stop the scroll programatically when there are three items visible. Is that even possible... Any code snippets, pseudo code, algo would help me.
You can set an OnScrollListener, and then store the value from absListView.getScrollY() each sample and compare it the previous sample to compute the velocity of the scroll. Once that drops below a threshold you define, you can take over scrolling.

Animating a View while ListView is scrolling not working

I'm trying to achieve the effect that the Google+ Android app has where there is a View that sits at the bottom of the screen, and when the user scrolls the ListView that sits behind it UP the View animates down, off screen. When the user scrolls the ListView down, even slightly, the View animates back up, on screen.
I've set up a GestureDetector, that is giving me callbacks for the scroll event on my ListView, and the callbacks are constant as I scroll so I know that part is working.
In my callback I'm trying to use the ViewPropertyAnimator to animate my y value as such:
headerView.animate().yBy(distanceY).start();
Nothing happens until I stop scrolling. Is there any way to throw this animation in with the ListView scroll on the UI thread? I get the feeling it's waiting.
I've been fighting this one also. The trick I ended up using was to replace
headerView.animate().yBy(distanceY).start();
with
headerView.setTranslationY(floatValue);
Hope this helps!

Categories

Resources