团队冲刺第二天
继续开局动画任然有部分未完成
创建一个SplashActivity
package com.example.project1;
import com.example.project1.R;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.WindowManager;
import androidx.appcompat.app.AppCompatActivity;
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//隐藏状态栏
getSupportActionBar().hide();//隐藏标题栏
setContentView(R.layout.activity_splash);
Thread myThread=new Thread(){//创建子线程
@Override
public void run() {
try{
sleep(2000);//使程序休眠两秒
Intent it=new Intent(getApplicationContext(),MainActivity.class);//启动MainActivity
startActivity(it);
finish();//关闭当前活动
}catch (Exception e){
e.printStackTrace();
}
}
};
myThread.start();//启动线程
}
}
注意getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);getSupportActionBar().hide();需要在setContentView(R.layout.activity_splash);之前执行
4.修改AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.project1">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
</activity>
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>