Reputation: 83
In my Android project I use Splash Screen API to add splash screen to my app. My theme that I apply to application in Manifest looks like this:
<style name="Launcher" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/background</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
<item name="windowSplashScreenIconBackgroundColor">@color/orange</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>
@color/orange
in windowSplashScreenIconBackgroundColor
should add circle shaped backround around icon. However, background is not added, there is just an icon and a background.
I add corresponding theme to my app as following:
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name_label"
android:theme="@style/Launcher">
I tried to change splash screen windowSplashScreenBackground
to orange
and it worked, so the problem is not that my theme is ignore somehow.
Upvotes: 6
Views: 4697
Reputation: 1881
If you want to override windowSplashScreenIconBackgroundColor
, you have to extend Theme.SplashScreen.IconBackground
theme, not the Theme.SplashScreen
. Something like this:
<style name="Launcher" parent="Theme.SplashScreen.IconBackground">
<item name="windowSplashScreenBackground">@color/background</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
<item name="windowSplashScreenIconBackgroundColor">@color/orange</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>
Upvotes: 6
Reputation: 113
As shown on the Splash Screen Api, Make sure you prepend the item name with android:
For example, replace:
<item name="windowSplashScreenBackground">@color/background</item>
with:
<item name="android:windowSplashScreenBackground">@color/background</item>
This is what I have:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--Splash Screen api: https://developer.android.com/develop/ui/views/launch/splash-screen#set-theme-->
<style name="Theme.MyApp" parent="@android:style/Theme.Material.NoActionBar">
<!--fill the background with a specific single color-->
<item name="android:windowSplashScreenBackground">@color/dark</item>
<!--background behind the splash screen icon TODO this is not working -->
<item name="android:windowSplashScreenIconBackgroundColor">@color/dark</item>
</style>
</resources>
Upvotes: -1