1.如果设置成完全透明
在Manifest.xml中给要设置成背景透明的acticity增加属性:android:theme="@android:style/Theme.Translucent"
2.如果想把背景设置成某个颜色
(1)在/value目录下增加文件color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="light_drak">#50ffffff</color>
</resources>
(2)在/value目录下增加文件style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Transparent">
<item name="android:windowBackground">@color/light_drak</item>
<item name="android:windowIsTranslucent">true</item>
</style>
</resources>
(3)在Manifest.xml中给要设置成背景透明的acticity增加属性:android:theme="@style/Transparent"
这样就可以了
本文介绍如何在Android应用中为特定Activity设置完全透明背景或指定颜色背景的方法。通过修改Manifest文件及创建自定义样式文件实现。

1万+

被折叠的 条评论
为什么被折叠?



