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.
Related
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.
Trying to animate a search bar result, which is a listView contained in a FrameLayout. Basically, all it needs to do is when the search button is pressed, the listView drops down along with the ListItems populated by a listAdapter. Right now, I cannot find a way to animate this outside of the adapter's getView method. However, if I animate the adapter's getView method, this animation would animate every single time the listView changes, which is not desired in my case.
The list populates after nofityDataSetChanged is called, so how would I be able to know the size of the listView before it's fully populated? or what exactly is the right way of doing this.
I just need it to animate on the first time. Therefore, the question is is there a more elegant way of animating ListView without changing anything in the ListViewAdapters.
Thanks for the help!
I have some problem with animation on RecyclerView
I have chat list with lot of messages. Each message is removing with delay (20s) and animation fadeout(0.3s). All work fine but it look strange sometime. Because if message is removing then all item below going up during first item is removing (fadeout). It looks like cumulative views on first position.
I am thinking about start animation before remove item. But it is not good idea. Also I thought about combining removing animation with scrolling the removing view.
One thing you can do is animate/collapse the height of the item view from its full height to 0, then remove the item from the adapter and refresh after that animation is complete.
I have a listView, with a footer attached to it, which is Button. This Button works fine when there is no Scrolling involved.
When the listView is scrolling, it becomes unclickable, like the other items in the ListView. Since it takes some time after the View have reached bottom, and the View actually stops "Scrolling", the footer(Button) is unclickable for a sec or 2. Is it possible to make an item, in this case a ListView footer, clickable while the ListView is scrolling? Or another clever solution to this issue?
try to make the button.setClickable(true). it should be clickable during the scrolling
This sounds like another one of a very long list of problems with ListView stealing touch events from its child views. The solution is to use RecyclerView instead. ListView is essentially deprecated and RecyclerView is the replacement.
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