Android 12+ 的动画闪屏界面 API 在实现时需要注意以下几点:
其中,@drawable/splash_screen 是动画闪屏界面的背景图片,@color/blue 和 @color/blue_dark 是导航栏和状态栏的颜色。
其中,@drawable/animated_splash_screen 是动画闪屏界面的资源文件,android.app.splash_screen_duration 是动画持续的时间,单位为毫秒。
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// 启动动画闪屏界面
SplashScreen.show(this, R.drawable.animated_splash_screen,
new SplashScreen.OnSplashScreenFinishedListener() {
@Override
public void onSplashScreenFinished() {
// 动画播放完毕后,跳转至主界面
Intent intent = new Intent(MainActivity.this,
HomeActivity.class);
startActivity(intent);
finish();
}
});
}
其中,SplashScreen 是一个自定义的类,需要在 MainActivity.java 文件中进行引用。