So I've been doing some reading for the past few hours and I understand that calling start() on an AnimationDrawable before the Drawable/ImageView is fully attached will not start the animation. This seems pretty consistent with the usual UI initialization process (like view's dimensions being returned as 0 right after adding the view).
I imagine that this same issue is at fault when I try to start the animation from the getView() method of an Adapter. Using a delayed Runnable that performs the start() call solves this problem but is clearly not a desirable solution.
Is there any way to receive a callback once ListView's items are "fully attached"?
According to the documentation, you must wait until the
View
is attached to the window before starting animation. Therefor, you should add anOnAttachStateChangeListener
to the view that will execute when it has been attached, and start the animation from there.I've tried starting the animation in a
Runnable
in theView
'spost()
method, and that didn't work. The above method is the only way I've reliably been to have animation start in aListView
.