首页 > 代码库 > Android 应用启动动画代码

Android 应用启动动画代码

requestWindowFeature(Window.FEATURE_NO_TITLE);//设置无标题
setContentView(R.layout.activity_main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏
ImageView welcomeImg = (ImageView) findViewById(R.id.iv);//启动时显示的图片
AlphaAnimation anima = new AlphaAnimation(0.3f, 1.0f);//创建一个透明度从0.3 慢慢到不透明的原图的动画效果
anima.setDuration(3000);// 设置动画显示时间
welcomeImg.startAnimation(anima);//设置启动时图片的动画
anima.setAnimationListener(new AnimationImpl());//设置动画监听
 private class AnimationImpl implements AnimationListener {//动画监听

  @Override   public void onAnimationStart(Animation animation) { //   welcomeImg.setBackgroundResource(R.drawable.ic_launcher);   }

  @Override   public void onAnimationEnd(Animation animation) {    Intent intent = new Intent(MainActivity.this, OtherActivity.class);

   startActivity(intent);    finish();   }

  @Override   public void onAnimationRepeat(Animation animation) {

  }  }