Skip to main content

DevBytes: Animating ListView Deletion

It's Friday: must be time for another DevBytes episode.



Finally, here is the DevBytes episode around the ListView animation demo in the talk A Moving Experience that I gave with Romain Guy at Google I/O last month.



The code is nearly the same as that in the I/O talk, except I tweaked it to make it more general-purpose. Specifically, it no longer depends on the setHasTransientState() method (introduced in Jellybean 4.1) to keep the views around while fiddling with layout. Instead, it uses an adapter with stable itemIds, and uses those Ids to track where the content is before and after layout.



As written, the code is still dependent on Android 4.1, but that's only because of the use of ViewPropertyAnimator.withEndAction() method, which is really just syntactic sugar around adding a listener and running the end-action code in the onAnimationEnd() callback. So you could totally port this code all the way back to Android 3.1 (when ViewPropertyAnimator was introduced) or even 3.0 (if you use ObjectAnimator instead).



Watch the video. Check out the code. Play with ListView. Animate. Enjoy.



A Moving Experience: http://www.youtube.com/watch?v=ihzZrS69i_s



DevBytes on YouTube: http://www.youtube.com/playlist?list=PLWz5rJ2EKKc_XOgcRukSoKKjewFJZrKV0



Code: http://developer.android.com/shareables/devbytes/ListViewRemovalAnimation.zip





Comments

Popular posts from this blog

2023 Josef Newgarden

Een paar weken geleden won Josef Newgarden de Indianapolis 500. GreenLight Models gaat dit model produceren in de schaal 1/18. Plaats hier je pre-order. Kijkerstip! Samen met Scott McLaughlin, zijn Penske teamgenoot heeft Josef Newgarden een zeer komsiche youtube serie met flauwe grappen genaamd Bus Bros!