Christopher Perry Christopher Perry - 2 months ago 6x
Android Question

Having trouble animating listview layout

I want the items in the listview to slide in one at a time from left to right. I have the following in res/anim/slide_right.xml

<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="" android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="150" />

And in my onCreate method in my ListActivity I have:

LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(this, R.anim.slide_right);

When I run it, I get a
caused by
Unknown layout animation name: set

What am I doing wrong?


I had the same problem and I seem to have solved it. I think this problem is similar to this one:

I have posted my answer over there over here as well (with some edits). You will have to define a second XML file that has a layoutAnimation element in it:

"If you want to apply an animation using android:layoutAnimation (or using loadLayoutAnimation), it seems that you have to define an extra XML file that refers to your animation (scale, set, translate, etc...). You can find an example here:

For example, your second xml file would look like this (let's call it example.xml):

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="" 

You can then refer to this animation in your layout file:


(or in your code using loadLayoutAnimation)


Hope this helps.