我们目前正在通过新的 Splashscreen API 实现启动画面。我们正在遵循迁移指南。背景颜色设置正确(按windowSplashScreenBackground
),但图标不可见,无论是在模拟器上还是在物理设备上。
构建.gradle
android {
compileSdkVersion 31
...
}
dependencies {
implementation "androidx.core:core-splashscreen:1.0.0-alpha01"
...
}
值-v31/themes.xml
<style name="AppTheme" parent="Theme.SplashScreen">
<item name="postSplashScreenTheme">@style/AppThemeCompat</item>
<item name="windowSplashScreenBackground">@android:color/black</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
<item name="windowSplashScreenAnimationDuration">200</item>
</style>
AndroidManifest.xml
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
...
</application>
MainActivity.kt
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen()
...
}