第一步
在xml中
<ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/image" android:src="@mipmap/ic_launcher" />
第二步
在Maintivity中
Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.alpha_from); image.setAnimation(animation); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { Intent intent = new Intent(MainActivity.this, Main2Activity.class); startActivity(intent); } @Override public void onAnimationRepeat(Animation animation) { } });
第三步
在anim_alphaxml中
<?xml version="1.0" encoding="utf-8"?> <alpha xmlns:android="http://schemas.android.com/apk/res/android" android:fromAlpha="0.1" android:toAlpha="1" android:duration="3000" android:repeatCount="3" > </alpha>