你需要使用动画来实现,首先要创建一个AnimationDrawable。
第一步是创建一个AnimationDrawable:
- 创建/res/anim/anim_android.xml文件。
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"android:oneshot="false">
<item android:drawable="@drawable/android_1"
android:duration="100"/>
<item android:drawable="@drawable/android_2"
android:duration="100"/>
<item android:drawable="@drawable/android_3"
android:duration="100"/>
<item android:drawable="@drawable/android_4"
android:duration="100"/>
<item android:drawable="@drawable/android_5"
android:duration="100"/>
<item android:drawable="@drawable/android_6"
android:duration="100"/>
<item android:drawable="@drawable/android_7"
android:duration="100"/>
</animation-list>
-添加一个ImageView,并设置android:src="@anim/anim_android"属性。
<ImageView
android:id="@+id/myanimation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@anim/anim_android" />
第二步
- 在您的活动中创建AnimationDrawable和Animation
AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getDrawable();
animationDrawable.setOneShot(true);
animationDrawable.start();
Animation animation = AnimationUtils.loadAnimation(YourActivity.this, android.R.anim.fade_in);
imageView.setAnimation(animation);
animation.start();
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Animation fadeOut = AnimationUtils.loadAnimation(YourActivity.this, android.R.anim.fade_out);
imageView.startAnimation(fadeOut);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
你不需要处理程序。