Android: How to code layoutAnimation instead of xml

Viewed 963

I'm going to give layout animation to item of ListView, which I used android:layoutAnimation before.

<LinearLayout
         ...
         android:layoutAnimation="@anim/layout_anim" />

// ../res/anim
<layoutAnimation 
         xmlns:android="http://schemas.android.com/apk/res/android"
         android:animation="@anim/slide_up" />

I tried to give following codes in adapter.

public View getView(int position, View convertView, ViewGroup parent) {
        ...
        Animation animation = AnimationUtils.loadAnimation(context, R.anim.slide_up);
        v.startAnimation(animation);

        return v;
}

And it works but the slide_up animation is implemented by full activity's level, not the item level. It appears from bottom of the activity. Originally it should appear from the bottom of item.

What was I wrong?

1 Answers
Related