Android中设置启动动画
- 以Alphaanimation为例
思路:在启动时设置一个Activity作为动画的载体,在动画结束后跳转到另一个界面。 XML布局:在布局中加入一个ImageView,fill_parent
在启动Activity中
image = (ImageView) findViewById(R.id.welcome);
AnimationSet animationSet = new AnimationSet(true);
AlphaAnimation alphaAnimation = new AlphaAnimation(0,1);
alphaAnimation.setDuration(1000);
animationSet.addAnimation(alphaAnimation);
image.startAnimation(alphaAnimation);
alphaAnimation.setAnimationListener(new Animation.AnimationListener() {@Override
public void onAnimationStart(Animation animation) {
image.setBackgroundResource(R.drawable.welcome);
}
@Override
public void onAnimationEnd(Animation animation) {
Intent intent = new Intent(MainActivity.this, Second.class);
startActivity(intent);
finish();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
还没有评论,来说两句吧...