【问题标题】:Splashscreen API not showing iconSplashscreen API 未显示图标
【发布时间】:2021-10-21 05:22:23
【问题描述】:

我们目前正在通过新的 Splashscreen API 实现启动画面。我们正在关注migration guide。背景颜色设置正确(windowSplashScreenBackground),但图标不可见,无论是在模拟器上还是在物理设备上。

build.gradle

android {
    compileSdkVersion 31
    ...
}

dependencies {
    implementation "androidx.core:core-splashscreen:1.0.0-alpha01"
    ...
}

values-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()
    ...
}

【问题讨论】:

    标签: android androidx android-12


    【解决方案1】:

    我正在直接回答这个问题,因为我们在一两个小时内找到了可以从其他开发人员那里获得的解决方案:

    从 Android Studio 启动应用时,Splashscreen API 设置的图标不起作用。如果应用程序关闭然后重新启动,则图标会正确显示。

    由于此库的早期 alpha 状态可能存在此错误,据称将在 Splashscreen API 的未来版本中修复。

    【讨论】:

    • 有同样的问题,但图标从不显示,虽然使用的是 alpha2
    猜你喜欢
    • 1970-01-01
    • 2021-04-10
    • 2021-01-23
    • 2014-03-18
    • 1970-01-01
    • 2013-07-05
    • 2017-09-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多