1、如图
2、分析
1)使用了透明动画AlphaAnimation
2)根据id找到布局文件view ,把动画设置到view
3)设置动画的监听事件,在onAnimationEnd事件后进行跳转到引导页面PagerActivity
3、源码
public class WelcomeActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
//1.拿到当前acitivity的layout的view
//2.绑定透明度变化的动画
//3.动画执行完毕后,进入主页面
View view = findViewById(R.id.layout_welcome);
AlphaAnimation anim = new AlphaAnimation(0.1f, 1.0f);
anim.setDuration(3000);
view.startAnimation(anim);
anim.setAnimationListener(listener);
}
AnimationListener listener = new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
startActivity(new Intent(WelcomeActivity.this, PagerActivity.class));
finish();
}
};
@Override
public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
return false;//表示按键不处理
}
}
4、布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_welcome"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f0f0f0" >
<ImageView
android:id="@+id/jing_girl_img"
style="@style/ImageViewCenter"
android:layout_marginTop="60dp"
android:src="@drawable/jing_gril" />
<ImageView
android:id="@+id/know_img"
style="@style/ImageViewCenter"
android:layout_below="@id/jing_girl_img"
android:layout_marginTop="30dp"
android:src="@drawable/know_icon" />
<ImageView
android:id="@+id/copyright"
style="@style/ImageViewCenter"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:src="@drawable/copyright" />
</RelativeLayout>