Android 启动画面,不透明背景不起作用

标签 android transparent splash-screen

我正在尝试让启动画面的背景变得不透明/透明。我在值中制作了一个 colors.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="translucent_black">#00000000</color>
</resources>

然后我有我的 splash.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="@color/translucent_black">
    <ImageView android:layout_width="wrap_content" android:id="@+id/imageView1"
        android:src="@drawable/splash" android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_centerInParent="true"></ImageView>

</RelativeLayout>

我觉得我应该在 list 中添加一些东西,但我总是在放入 Activity 时出错。另外,如果你真的感觉很活泼,我也可以想办法让标题栏消失。再次感谢。

最佳答案

简单方法

指定使用半透明主题的 Activity (在 manifest.xml 中):

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

高级方法

如果您想要更多的可定制性,您可以创建自己的主题来扩展半透明主题 (manifest.xml):

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

在 styles.xml 中:

<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="MyTranslucentTheme" parent="android:Theme.Translucent">
    <item name="android:windowBackground">@color/transparent_black</item>
</style>

<color name="transparent_black">#DA000000</color>
</resources>

关于Android 启动画面,不透明背景不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6229186/

相关文章:

WPF 以编程方式禁用启动画面

android - Android Gradle Plugin 3.1在运行即时运行时在合并 list 中给出错误

android - 添加非 Jar 格式的库

javascript - 如何创建一个半透明的弹出框?

vb.net - 使 vb.net 窗体的边框半透明

android - Android 上带有多个图像的启动屏幕

按钮单击上的 Android 选项菜单

android - 如何检测我的 Android 应用程序是否显示?

c# - 我可以在 WinForms 中的 PictureBox 上创建透明背景吗?