ListView items animation: adding one by one with some delay - android

Wanna implement the filling of my ListView with the effect like that: the first item rotates X and fades in, later the second one and so on.
One way to do it is clear - add items one by one to the adapter (just like in that post), while the animations are handled by LayoutTransition object, which I set in advance.
However, I have a strange feeling, like it'd be somewhat a crutch to add items asycnchoniously just in sake of animation effect. Does anybody know how to do it better?
UPD:
Some details: I want items to be animated only when the underlying data changes, for instance, the server sends new info and the list updates, just like the old departure boards in airports.

Use a LayoutAnimationController....
LayoutAnimationController lac = new LayoutAnimationController(AnimationUtils.loadAnimation(getActivity(), R.anim.table_row_appear), 0.5f); //0.5f == time between appearance of listview items.
listView.setLayoutAnimation(lac);
Whenever you want to run the animation :
listView.startLayoutAnimation();

Finally, I ended up with using the LinearLayout instead of ListView because of the view reusage, that reruns the animation for every view whenever it's showed up again.
But I did it just because I didn't have too many items to show. Another approach, as I guess, is to load animations in adapter, compute delay in accordance with item position and to store the map with the info, wether the view has already been animated in or not.

You can create an animation(transition + fade or any other effect you want) and add the animation to the Layout (view) that you return in "getView"
the animation shall take in consideration the "position" parameter to create the delay when the animation is started.
enjoy
daniel

Related

Submitting a completely new list to recycler view with list adapter causes flickering/laggy animation

i am using a recycler view with a list adapter. When submitting a list with a completely or almost completely different items the animation doesn't look good. Another problem is that i have no control on the scroll position as scroll to position is not processed as expected. It makes perfect sense to reset the scroll position to zero when the data is changed.
I ended up setting up a new adapter when switching all the data.
Would be helpful to have a better solution.
I would expect to have a method where you notify the adapter/recycler view that you want to switch all the data without trying to applying the diff mechanism and animating the changes.
I would like to be able to animate the appearance of the new list but avoid trying to animate what actually changed.

Access Adapter items of Recyclerview

I'm using Recyclerview to show a list. I want to delete some items like IOS. In my listview template I have added a button to delete item which is invisible by default. In my activity I have another button attached at bottom (Not part of listview) and on tap of this button I want to make all delete buttons of listview visible.
My Question is how can I get reference to all delete buttons of listview in activity and is it the right way to do this?
Thanks
Assuming you have ViewHolders set up, you already have references to all the buttons in your list. All you have to do is to make them visible for every item in the list with a simple loop.
In case you haven't implemented ViewHolders I suggest you check out the documentation and take a look at some simple tutorials on how to use them.
On a side note. If I understood correctly you're making a bottom tab for your app and since you referenced iOS I gotta say this; Remember that Android and iOS are two unique operating systems with their own ways of handling things. Check out Googles pure Android documentation.
In your question title you say RecyclerView, but in your text you say ListView. The solution is similar either way, but it's best to be perfectly clear what you're doing.
In either case, there are at least two different solutions.
First, you could use a boolean flag to determine if all the the item buttons should be showing or not. You check this flag at the time the item view is inflated or created and toggle the button accordingly. If the boolean flag is ever changed, the easiest thing to do is tell the RecyclerView/ListView that the underlying data has changed and to redraw all the views. Call notifyDatasetChanged on the adapter.
The other thing you can do at the time the item buttons should change is iterate all the visible item views, find the button, and change its visibility. With RecyclerView, you can do this, and with ListView you can do this.

RecyclerView insert / remove animations

When you watch carefully, the insert animation in a RecyclerView works in 2 steps :
1) White space expands to make room for the new item
2) The item is animated in
Same thing for removal, reverse order
Examples :
https://github.com/wasabeef/recyclerview-animators
http://www.grokkingandroid.com/first-glance-androids-recyclerview/
The second step can be customized easily with the ItemAnimator class, but I cannot find any information on the first step. It happens to be very ugly with my layout (continuous color on the side).
LayoutAnimationController seems like a possible candidate to manage the first step, but adding a new one does not change anything, and following it with logs in setLayoutAnimationListener stays silent.
I cannot even disable this step, which would allow me to manage the animation manually in onBindViewHolder.
Actually sometimes the first step does not seem to fire, but I cannot explain why. I manage all the operations with notifyItem*, no notifyDataSetChanged.

Android gridview animation (ordering) the list when removing or adding

When I remove an item from a gridview, it fades out (because I start an animation) and all the other items change their place "at once".
Is there a simple way to animate all the other items to move, so the empty spot get filled up nicely animated, and not "at once"?
I would like to do the same for adding a new Item: all existing items will move animated and make a free place at the start of the grid where the new item will appear. I could of course do this by animating every item on itself, doing something different for the items at the end of a line, etc. But I would think there is already something prepared for this?
I checked out http://developer.android.com/reference/android/view/animation/GridLayoutAnimationController.html
But that only seems to be useful for showing the grid come into view, not when it already is in view.
Also, if you know an open source program that implemented this, please let me know.
This helped me a lot, you can at least use the animations in this project, but maybe the whole thing will suit you:
https://github.com/mrKlar/PagedDragDropGrid
example on youtube here:
http://www.youtube.com/watch?v=FYTSRfthSuQ
It looks like a gridview but isn't a gridview object. I used some of the code to change my own (android) gridview, but that was a great deal of work. If you can, just use this whole project.

Android Smooth fill the list with new items from top

so here is my setup:
I have a listview with a custom adapter and i have methods which add new items to the list from the top. This works without an issue but i am looking to tweak it and make it better.
so here is my issue: right now when i call notifyDataSetChanged() the items are added to the list but that happens instantly and it is kinda rough and you can't really see which items have been added.
what i want to do is actually have some sort of animation when the items are added so it appears like the old ones are pushed down and that be visible to the user (maybe last 300 ms per item or 2 seconds for a total of maybe 5-10 items)
Thanks for any help you can give me.
You can try to make tween animation for the listView. But I am not sure whether only new or all items are going o be animated when notifyDataSetChanged is called

Categories

Resources