1 package com.leolu.fristapp;
2
3 import android.app.Activity;
4 import android.os.Bundle;
5 import android.view.View;
6 import android.view.animation.AlphaAnimation;
7 import android.view.animation.Animation;
8 import android.view.animation.Animation.AnimationListener;
9
10 public class SplashPage extends Activity {
11
12 @Override
13 protected void onCreate(Bundle savedInstanceState) {
14 super.onCreate(savedInstanceState);
15
16 //获取activity_splash_page.xml布局
17 View view = View.inflate(this, R.layout.activity_splash_page, null);
18 //加载布局
19 setContentView(view);
20
21 //设置动画,渐显渐隐可用AlphaAnimation,变形动画用RotateAnimation,位移动画用TranslateAnimation
22 //第一个参数值0.3f为开始的透明度为30%,第二个参数值1.0f为结束的透明度为100%,即不透明。
23 AlphaAnimation alphaAnimation = new AlphaAnimation(0.3f, 1.0f);
24
25 //给动画设置持续时间,如果不设置,则时间为0,动画就看不到效果
26 alphaAnimation.setDuration(2000);
27
28 //给我们的背景运行动画
29 view.startAnimation(alphaAnimation);
30
31 //设置动画监听
32 alphaAnimation.setAnimationListener(new AnimationListener() {
33
34 @Override //动画一开始就执行以下方法
35 public void onAnimationStart(Animation animation) {
36
37 }
38
39 @Override //动画重复时执行以下方法
40 public void onAnimationRepeat(Animation animation) {
41
42 }
43
44 @Override //动画结束时执行以下方法
45 public void onAnimationEnd(Animation animation) {
46
47 }
48 });
49
50 }
51
52
53 }