我为两个图像创建了两个动画,它工作正常,但我希望在第一个动画完成时开始第二个动画。
编码:
package com.example.animatest;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class animation001 extends Activity {
private ImageView image1;
private ImageView image2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image1 = (ImageView) findViewById(R.id.imageView1);
image2 = (ImageView) findViewById(R.id.imageView2);
final Animation animTranslate1 = AnimationUtils.loadAnimation(this,
R.anim.translate);
final Animation animTranslate2 = AnimationUtils.loadAnimation(this,
R.anim.translate2);
image1.startAnimation(animTranslate1);
image2.startAnimation(animTranslate2);
}
}
这是第一个动画 xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<translate
android:fromXDelta="-100%p"
android:toXDelta="0"
android:duration="1500"
android:repeatCount="0"
android:repeatMode="reverse" />
</set>
这是第二个动画 xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<translate
android:fromYDelta="-100%p"
android:toYDelta="0"
android:duration="25000"
android:repeatCount="0"
android:repeatMode="reverse" />
</set>