sam_0829 sam_0829 - 1 month ago 6
Android Question

How can I animate one View after another instead of all at the same time?

I am adding

dynamically to a
. I want to animate each
so they slide in one after another from the left. This is what I currently have:

for ( int i=0; i < SOME_SIZE; i ++ ) {

public View addLessonsView(int position) {

LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.row_memory_book_lessons, null);

TextView tvLesson = (TextView) v.findViewById(;

tvLesson.setText(mLessonList.get(position).getLessonNumber() + " - " + mLessonList.get(position).getLessonName());

Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.slide_left_to_right);

v.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {

return v;

The problem is that all of the
happen at the same time instead of one after another. How can I slide the
in one after another?


You are starting all Animations at the same time which is why all of the Views slide in at the same time. What you need to do is add a start offset to each Animation which corresponds to its position in the List.

For example to delay each Animation to play 75ms after the one before it you can do this:

Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.slide_left_to_right);

final long startOffset = position * 75;


Additionally I suggest you switch to the newer Animator API which was introduced Android 3.0 (Honeycomb). The old view animations you are using are outdated to say the least.

Click here to get started with the newer API.