Raj*_*aju 9 android splash-screen android-12
我正在尝试实现启动画面。
我按照闪屏 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)
改变这个:
<item name="postSplashScreenTheme">@style/Theme.SplashScreenApi</item>
Run Code Online (Sandbox Code Playgroud)
对此:
<item name="postSplashScreenTheme">@style/AppTheme</item>
Run Code Online (Sandbox Code Playgroud)
(其中AppTheme是您的主主题名称)
此外,无需在 Activity 和应用程序中都应用 Splash 主题。所以我建议您在应用程序标签中更改此设置:
android:theme="@style/Theme.App.Start"
Run Code Online (Sandbox Code Playgroud)
对此:
android:theme="@style/AppTheme"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3007 次 |
| 最近记录: |