import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.widget.ImageView; public class MainActivity extends AppCompatActivity { private ImageView imag; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); initData(); } private void initData() { AlphaAnimation alp=new AlphaAnimation(0,1); alp.setDuration(3000); imag.setAnimation(alp); alp.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { Intent itent = new Intent(MainActivity.this,Main2Activity.class); startActivity(itent); } @Override public void onAnimationRepeat(Animation animation) { } }); } private void initView() { imag = (ImageView) findViewById(R.id.imag); } }
<ImageView android:id="@+id/imag" android:src="@mipmap/ic_launcher" android:layout_width="wrap_content" android:layout_height="wrap_content" />