【网学网提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了Android 欢迎程序的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
/**
*欢迎界面
*@author小建枫叶
*
*/
publicclassWelcomeActivityextendsActivityimplementsAnimationListener{
privateImageViewimageView=null;
privateAnimationalphaAnimation=null;
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
imageView=(ImageView)findViewById(R.id.welcome_image_view);
alphaAnimation=AnimationUtils.loadAnimation(this,R.anim.welcome_alpha);
alphaAnimation.setFillEnabled(true);//启动Fill保持
alphaAnimation.setFillAfter(true);//设置动画的最后一帧是保持在View上面
imageView.setAnimation(alphaAnimation);
alphaAnimation.setAnimationListener(this);//为动画设置监听
}
@Override
publicvoidonAnimationStart(Animationanimation){
}
@Override
publicvoidonAnimationEnd(Animationanimation){
//动画结束时结束欢迎界面并转到软件的主界面
Intentintent=newIntent(this,MainActivity.class);
startActivity(intent);
this.finish();
}
@Override
publicvoidonAnimationRepeat(Animationanimation){
}
@Override
publicbooleanonKeyDown(intkeyCode,KeyEventevent){
//在欢迎界面屏蔽BACK键
if(keyCode==KeyEvent.KEYCODE_BACK){
returnfalse;
}
returnfalse;
}
}
/**
*欢迎界面
*@author小建枫叶
*
*/
publicclassWelcomeActivityextendsActivityimplementsAnimationListener{
privateImageViewimageView=null;
privateAnimationalphaAnimation=null;
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
imageView=(ImageView)findViewById(R.id.welcome_image_view);
alphaAnimation=AnimationUtils.loadAnimation(this,R.anim.welcome_alpha);
alphaAnimation.setFillEnabled(true);//启动Fill保持
alphaAnimation.setFillAfter(true);//设置动画的最后一帧是保持在View上面
imageView.setAnimation(alphaAnimation);
alphaAnimation.setAnimationListener(this);//为动画设置监听
}
@Override
publicvoidonAnimationStart(Animationanimation){
}
@Override
publicvoidonAnimationEnd(Animationanimation){
//动画结束时结束欢迎界面并转到软件的主界面
Intentintent=newIntent(this,MainActivity.class);
startActivity(intent);
this.finish();
}
@Override
publicvoidonAnimationRepeat(Animationanimation){
}
@Override
publicbooleanonKeyDown(intkeyCode,KeyEventevent){
//在欢迎界面屏蔽BACK键
if(keyCode==KeyEvent
.KEYCODE_BACK){
returnfalse;
}
returnfalse;
}
}
动画welcome_alpha.xml
Xml代码
android:interpolator="@android:anim/accelerate_interpolator">
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="2000"
/>
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:startOffset="3000"//延迟3秒再开始
android:duration="3000"
/>
android:interpolator="@android:anim/accelerate_interpolator">
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="2000"
/>
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:startOffset="3000"//延迟3秒再开始
android:duration="3000"
/>
布局welcome.xml
Xml代码
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_vertical|center_horizontal">
android:id="@+id/welcome_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/welcome"
/>