小编Alm*_*KhR的帖子

Android:如何在新的 SplashScreen API 中将可绘制对象设置为 windowSplashScreenBackground 参数?

我想使用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)

但它解决了一个问题并消耗了另一个问题。屏幕背景接受渐变但徽标变得不可见

android splash-screen android-theme

30
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

android-theme ×1

splash-screen ×1