我使用透明背景的 Inkscape 创建了一个简单的图像,alpha(0) 并且在中心有一个小 Logo 。然后我将它应用到我的样式中,如下所示:
<style name="SplashScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">@drawable/splashscreen</item>
<item name="colorPrimary">@android:color/transparent</item>
<item name="colorPrimaryDark">@color/colorPrimary</item>
<item name="colorAccent">@color/loginHeaderBackground</item>
</style>
它工作正常,但是,我错过了我的主要目标,它显示一个带有中间图标而不是透明图标的黑屏。
我想要的(当应用开始启动时,用户应该仍能看到他们的手机背景)
我得到了什么
这是为什么?
最佳答案
有一个例子给你。我写了自定义主题并将这个主题添加到我的 Activity 中。您应该在 list 文件中添加此启动 Activity 。
<activity ...
android:theme="@android:style/Theme.TranslucentTheme"
.../>
样式.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="TranslucentTheme" parent="android:Theme.Translucent">
<item name="android:windowBackground">@color/transparent_black</item>
</style>
<color name="transparent_black">#DA000000</color>
</resources>
关于android - 如何将透明背景应用于 windowBackground,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54320365/