启动某项程序时我们往往都能看到不同的“开机动画”,千变万化的动画也只不过是四种基本动画衍变美化而成的。
	四种android动画效果:
	- 		alpha         渐变透明度动画效果
- 		scale         渐变尺寸伸缩动画效果
- 		 translate  画面转换位置移动动画效果
- 		rotate        画面转移旋转动画效果
	最简单的莫过于渐变透明效果,单单这一种就可完成渐隐渐现的动画效果(用于渐现渐隐的可以是整个欢迎页面也可以是欢迎页面里的一部分):
	1)、 在res里新建anim文件夹用来盛放动画定义的动作文件:
	<set xmlns:android="http://schemas.android.com/apk/res/android"    android:interpolator="@android:anim/accelerate_interpolator">    <alpha       android:fromAlpha="0.0"      android:toAlpha="1.0"      android:duration="2000"/>    <alpha       android:fromAlpha="1.0"      android:toAlpha="0.0"      android:startOffset="3000"      android:duration="3000"/>  </set>
 	fromalpha即开始的透明度,toalpha即结束时的透明度,duration为时间(单位毫秒)。
	2)、定义布局文件(layout):
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:gravity="center_vertical|center_horizontal"  android:orientation="vertical" >   <ImageView    android:id="@+id/welcom_logo"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:src="@drawable/welcome" /> </LinearLayout>
 	这里和以往没有任何不同,只需对要渐现渐隐的图片进行id标示。
	3)、实现方法(Activity):
	public class WelcomeActivity extends Activity implements AnimationListener { private ImageView imageView = null; private Animation alphaAnimation = null;  @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); imageView = (ImageView) findViewById(R.id.welcom_logo); alphaAnimation = AnimationUtils.loadAnimation(this,  R.anim.welcome_alpha); alphaAnimation.setFillEnabled(true);//启动Fill保持 alphaAnimation.setFillAfter(true);//设置动画的最后一帧是保留在view上的 imageView.setAnimation(alphaAnimation); alphaAnimation.setAnimationListener(this);  }  @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_welcome, menu); return true; }  @Override public void onAnimationEnd(Animation animation) { //动画结束时结束欢迎页面并跳转到主页面 Intent intent=new Intent(this,GroupActivity.class); startActivity(intent); this.finish();  }  @Override public void onAnimationRepeat(Animation animation) {   }  @Override public void onAnimationStart(Animation animation) {   } public boolean onKeyDown(int KeyCode,KeyEvent event){ //在欢迎页面屏蔽BACK键 if(KeyCode==KeyEvent.KEYCODE_BACK){  return false; } return false;  }} 	欢迎页面顾名思义只是装饰作用一闪而过不需要返回键进行操作。
	以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持VEVB武林网。
注:相关教程知识阅读请移步到Android开发频道。