How to Animate Addition or Removal of Android ListView Rows
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
ListView does not have the built-in item animation support that RecyclerView provides, so row insertion and removal animations usually need to be done manually. The general pattern is: animate the row view itself, update the backing data at the right moment, then notify the adapter. If you remove the data too early, the row disappears before the animation can be seen.
Important Reality Check
If you are building new Android UI, RecyclerView is usually the better choice because it has a proper item animation ecosystem. But if you are maintaining legacy ListView code, you can still create acceptable add and remove animations with a bit of manual control.
The key rule is:
- animate the visible row view
- update the adapter data after or during the animation in a controlled way
Basic Adapter Setup
Here is a simple ListView with a mutable list and ArrayAdapter.
That is enough for the data side. The animation logic comes next.
Animate Removal Of A Visible Row
For removal, a common pattern is to fade and collapse the row, then remove the item from the data set when the animation ends.
This works best when you already have the visible row view, such as from a button click inside that row.
Animate Addition
For insertion, do the reverse: add the item first so the row exists, then animate the new row when it becomes visible.
Then in your adapter's getView, detect newly inserted items and animate their appearance.
You will usually need a small piece of state, such as the last inserted position, so that only the intended row animates.
Why Timing Matters
The biggest source of bad-looking ListView animations is data timing.
If you call:
before animating the row, the row is gone immediately and there is nothing left to animate. The data change and the view animation must be coordinated.
This is the main difference between hand-rolled ListView animation and the more structured change handling in RecyclerView.
Stable IDs Help
If your adapter supports stable IDs, row transitions are easier to reason about because rows can be identified consistently across updates.
With legacy ListView, stable IDs are not a full item-animation system, but they still reduce UI confusion when data changes rapidly.
When To Prefer RecyclerView
If you need more than a simple fade or collapse, or if rows update frequently, consider migrating. RecyclerView with ListAdapter or DiffUtil provides a much better long-term path for animated list changes.
That does not mean ListView is unusable. It means manual animation effort grows quickly as the UI becomes more dynamic.
Common Pitfalls
- Removing the item from the data set before the row animation finishes.
- Animating the wrong row because the visible position and data position got out of sync.
- Calling
notifyDataSetChanged()repeatedly during an animation and causing flicker. - Building large, complex animation logic on top of
ListViewwhenRecyclerViewwould be a better fit. - Forgetting to reset properties such as alpha and height after reusing a row view.
Summary
- '
ListViewdoes not provide built-in row insertion and removal animation support likeRecyclerView.' - For removals, animate the row first and update the data set when the animation ends.
- For additions, insert the item and animate the new row as it appears.
- Keep data timing and view timing coordinated or the effect will look broken.
- If the list behavior is becoming complex, migrate to
RecyclerViewinstead of extendingListViewfurther.

