小编Raj*_*aju的帖子

深色模式下不支持闪屏 API

我正在尝试实现启动画面。

我按照闪屏 API 方法实现了 implementation 'androidx.core:core-splashscreen:1.0.0-alpha02'

启动文件

<style name="Theme.App.Start" parent="Theme.SplashScreen">
  <item name="windowSplashScreenBackground">#FFF</item>
  <item name="windowSplashScreenAnimatedIcon">@drawable/ic_baseline_baby_changing_station_24</item>
  <item name="postSplashScreenTheme">@style/Theme.SplashScreenApi</item>
</style>
Run Code Online (Sandbox Code Playgroud)

splash.xml(用于暗模式)

<style name="Theme.App.Start" parent="Theme.SplashScreen">
   <item name="windowSplashScreenBackground">#3A3A3A</item>
   <item name="windowSplashScreenAnimatedIcon">@drawable/ic_baseline_baby_changing_station_24</item>
   <item name="postSplashScreenTheme">@style/Theme.SplashScreenApi</item>
</style>
Run Code Online (Sandbox Code Playgroud)

清单.xml

<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/Theme.App.Start">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:theme="@style/Theme.App.Start">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
</application>
Run Code Online (Sandbox Code Playgroud)

MainActivity.kt

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        installSplashScreen()

        setContentView(R.layout.activity_main)
    }
}
Run Code Online (Sandbox Code Playgroud)

深色模式下仍显示黑色图标
启动画面深色模式

并且在灯光模式下完美工作
启动画面灯光模式

设备名称:小米红米 Note 7 Pro,
Android 版本:Android 10 (SDK 29)

android splash-screen android-12

9
推荐指数
1
解决办法
3007
查看次数

标签 统计

android ×1

android-12 ×1

splash-screen ×1