我正在尝试让启动画面的背景变得不透明/透明。我在值中制作了一个 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/