【问题标题】:How can I apply a transparent background to the windowBackground如何将透明背景应用于 windowBackground
【发布时间】:2019-06-16 15:17:49
【问题描述】:

我使用 Inkscape 创建了一个简单的图像,带有透明背景,alpha(0),在中心,我有一个小徽标。然后我将它应用到我的样式中,如下所示:

<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>

它工作正常,但是,我错过了我的主要目标,它显示一个带有中间图标而不是透明图标的黑屏。

我想要什么(当应用启动时,用户应该仍然可以看到他们的手机背景)

我得到了什么

这是为什么?

【问题讨论】:

  • 你能张贴一张你想要什么和你有什么的图片吗?
  • 编辑了帖子

标签: android view background


【解决方案1】:

有一个例子给你。我编写了自定义主题,并将这个主题添加到我的活动中。您应该在清单文件中添加您的启动活动。

<activity ... 
    android:theme="@android:style/Theme.TranslucentTheme"
 .../>

styles.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>

【讨论】:

  • 就我而言,我想要一个透明的背景,中间有一个图标
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-08-04
  • 1970-01-01
  • 2011-03-08
  • 2012-07-27
  • 2015-08-06
  • 2011-09-17
相关资源
最近更新 更多