Android实例图解教程目录
http://blog.csdn.net/wyx100/article/details/45061407
在《开发一个新的android界面、界面跳转 看图学Android---Android 开发实例教程三、四》基础完成开机动画,开机界面的图片,在5.5秒内逐渐消失,显示主界面。
只修改StartActivity.java中代码以下部分
StartActivity.java源代码
package com.example.helloword; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.view.animation.AlphaAnimation; import android.view.animation.AnimationSet; import android.widget.ImageView; public class StartActivity extends Activity { /** Called when the activity is first created. */ private final int SPLASH_DISPLAY_LENGHT = 3000; //延迟三秒 private ImageView image=null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.start); image=(ImageView)findViewById(R.id.imageView1); AnimationSet animationset=new AnimationSet(true); AlphaAnimation alphaAnimation=new AlphaAnimation(1, 0);//AlphaAnimation(1, 0)图片逐渐变成透明,1指透明度为0%,0指透明度100% alphaAnimation.setDuration(5500); animationset.addAnimation(alphaAnimation); image.startAnimation(animationset); new Handler().postDelayed(new Runnable(){ @Override public void run() { Intent mainIntent = new Intent(StartActivity.this,MainActivity.class); //界面跳转定义 StartActivity.this.startActivity(mainIntent); //启动界面跳转 StartActivity.this.finish(); //界面跳转完成后,消除界面一 } }, SPLASH_DISPLAY_LENGHT); //界面一显示时长 } }
时间: 2024-10-20 21:37:55