Animation on part of item in recycler view - android

I am trying to implement a recycler view which will show items with rating and when ever rating changes it will flip the current rating with animation.
I am doing this on onBindView. The problem I am facing is, onBindView is called even view holder is partially visible ie. rating view is still not on screen and as a consequences it animate before its time.
Any help is appreciated. Thanks in advance.

You can listen for scroll events and determine which items have transitioned between non visible and fully visible.
Register a scroll callback with:
RecyclerView.addOnScrollListener
If you are using a LinearLayoutManager your callback can use the following methods to determine which items are visible:
LinearLayoutManager.findFirstVisibleItemPosition
LinearLayoutManager.findLastCompletelyVisibleItemPosition
It is up to you to track the changes in item state between non-visible and visible.

Related

Prevent RecyclerView item from detaching

I have a RecyclerView, one of its item views contains a TextureView. If I scroll this item outside the screen boundaries, the item view will be detached from RecyclerView, which leads to context loss in TextureView. TextureView will be redrawn again, if the item view will appear on the screen again.
My goal is to prevent this redrawing. For now, I see only one solution for this problem - prevent RecyclerView detach its item view. Is there any way to achieve this?
Try to Put this line in starting of onbindViewHolder.
holder.setIsRecyclable(false);

Creating a recycler view with certain requirements.

I am trying to create a specific type of recycler view with following requirements:
1) RecyclerView that would show one item per screen (1 row will take the size of screen).
2) When I scroll the recyclerview it should stop scrolling as soon as the next item is visible. (Captures the whole screen).
Please tell me if that is possible or not.
Do you have to use RecyclerView?
Probably you can do that with View Pager.
https://stackoverflow.com/a/22797619

RecyclerView: How to tell not to recycle?

I have a RecyclerView with expandable list items. That means when the user clicks on an item it gets expanded and additional information is appearing. If the user is clicking again the item gets collapsed so that the additional information is hiding again.
My problem now is the following:
When i expand the first item and scroll down a bit and up again the first item is collapsed again automatically but the internal state ofcourse still is at the expanded state so i cant expand it anymore. Also when the first item is expanded and i scroll down some of the items are in the expanded state too without showing the additional data and i cant expand it anymore.
So that means i have to somehow disable the recycling mechanic. How can i do that?
I think disabling the recycling mechanic is the wrong solution. The whole idea of the recyclerview is to do this. What you need to do is to preserve the state

Make Recycler View Inactive

I have a recycler view I'm using with a GridLayoutManager. When the user clicks on an item of view, a view is animatated with scale animation to display further details of the adapter item. I have a button to reverse this animation and remove the details off screen.
The problem is when the details view is displayed the user can still click on the recycler view and animate a different view. Can any tell me how to disable the recycler view?
I've tried rc_view.setEnabled(false);
rc_view.setClickable(false);
and I've followed this and none of them has disabled the recycler view.
Can anyone help?
Might sound stupid, but same thing happened to me on my menu (when clicking on open spaces the click events were passed to the recycler).
This was fixed by adding "clickable='true'" on the top view so it doesn't pass the click event to the recyclerview.
Let me know if this helps
Use recyclerView.setClickable(true)

Animation in ListView item doesn't work after scrolling

I have animation in one listview item. After scrolling list when list item with animation started not visible I am scrolling back to the listview item with animation but animation doesn't work anymore.
getView() method :
iv.setImageResource(R.drawable.anim);
iv.requestFocus();
((AnimationDrawable) iv.getDrawable()).start();
?
UPDATE:
Is it wrong question or there are not any ideas?
You are assuming that every time the view is been scrolled(or become visible to you), the animation will start playing. But it's not true, the view can be not visible an yet be in the memory, so when you are scrolling it and it become visible, the getView() method will not be called. This is why it is a bad practice to put animations inside a list. I suggest you to implement the entire view by yourself if this is something you most to do.

Categories

Resources