android - 如何将透明背景应用于 windowBackground

标签 android view background

我使用透明背景的 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/

相关文章:

javascript - 如何在嵌入式样式表中使用 javascript 变量作为背景?

android - 将 Android 权限拆分为多个应用程序/插件的最佳方式

android - 授权请求头 OAuth 2.0

c# - 您可以将不同的 View 模型发送到 View 吗?

java - 更改启用 JTextField 的背景颜色

css - 制作锁子甲背景主题

android - future 日期的 DateUtils.getRelativeTimeSpanString

android - 有选择地将不记名 token 添加到 Retrofit 中的 header 中

sorting - 订购 Backbone View 和集合

带有全文索引的 mysql View