我想使用Splash Screen API制作带有渐变背景和徽标的启动屏幕
像这样:
我对值是纯色的字段进行了样式设置windowSplashScreenBackground,效果很好:
<style name="Theme.MyApp.SplashScreen" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/blue</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
<item name="postSplashScreenTheme">@style/Theme.MyApp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
该属性windowSplashScreenBackground只能采用颜色。
有什么想法如何创建渐变背景吗?可能是这样的:
<style name="Theme.MyApp.SplashScreen" parent="Theme.SplashScreen">
...
<item name="windowSplashScreenBackground">@drawable/gradient_splash_screen_background</item>
...
</style>
Run Code Online (Sandbox Code Playgroud)
更新
我还尝试在字段中声明背景android:windowBackground而不是windowSplashScreenBackground
<style name="Theme.MyApp.SplashScreen" parent="Theme.SplashScreen">
<item name="android:windowBackground">@drawable/gradient_splash_screen_background</item>
<!-- <item name="windowSplashScreenBackground">@color/purple</item>-->
<!-- <item name="windowSplashScreenBackground">@drawable/splash_screen_layers</item>-->
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
<item name="postSplashScreenTheme">@style/Theme.MyApp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但它解决了一个问题并消耗了另一个问题。屏幕背景接受渐变但徽标变得不可见