import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.RelativeLayout;public classSplashActivity extends AppCompatActivity {
@Overrideprotected voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//AS下全屏隐藏标题栏代码
setContentView(R.layout.activity_splash);
RelativeLayout laoutsplsh=findViewById(R.id.activity_splash);
AlphaAnimation alphaAnimation=new AlphaAnimation(0.1f,1.0f);
alphaAnimation.setDuration(2200);
laoutsplsh.startAnimation(alphaAnimation);
alphaAnimation.setAnimationListener(newAnimation.AnimationListener() {
@Overridepublic voidonAnimationStart(Animation animation) {
}
@Overridepublic voidonAnimationEnd(Animation animation) {
Intent intent=new Intent(SplashActivity.this,MainActivity.class);//intent.setClass(getApplicationContext(),MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);//把那个MainActivity设置为栈底 意思就是防止你按返回键的时候返回到哪个启动欢迎界面
startActivity(intent);//载入主窗口
finish();
}
@Overridepublic voidonAnimationRepeat(Animation animation) {
}
});
}
}