仔细观察手机应用很多都用到了动画效果 那么咱们也做一个
除了位移没有使用 其他都有 布局随便放张图片
public class SplashActivity extends Activity { private RelativeLayout rlRoot; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); rlRoot = (RelativeLayout) findViewById(R.id.rl_root); // 旋转, 缩放, 渐变 // 旋转 RotateAnimation animRotate = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animRotate.setDuration(1000); animRotate.setFillAfter(true); // 缩放 ScaleAnimation animScale = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animScale.setDuration(1000);//动画持续时间 1秒 animScale.setFillAfter(true);//ture表示动画结束后停留在动画的最后位置,false表示动画结束后回到初始位置,默认为false。 // 渐变 AlphaAnimation animAlpha = new AlphaAnimation(0, 1); animAlpha.setDuration(2000); animAlpha.setFillAfter(true); // 动画集合 AnimationSet animSet = new AnimationSet(true); animSet.addAnimation(animRotate); animSet.addAnimation(animScale); animSet.addAnimation(animAlpha); rlRoot.startAnimation(animSet); animSet.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // 动画结束后跳主页面 startActivity(newIntent(getApplicationContext(),MainActivity.class)); finish(); } } }); } }