方法一、
在清单配置文件AndroidManifest.xml的设置主题
<activity android:name=".activities.MyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
方法二、
(由于Applicaiton使用了Theme的子类下面没有Translucent,又无法改变Application的Theme的情况下使用)
自定义主题
在Value文件夹下的styles.xml添加style
<!-- 透明主题 parent 为需要继承的父Theme,可与Application设置的Theme相同 --> <style name="transparency_theme_light" parent="@style/Theme.AppCompat.Light.NoActionBar"> <item name="android:background">@color/transparency</item> <item name="android:windowBackground">@color/transparency</item> <item name="android:windowIsTranslucent">true</item> </style>
transparency在color.xml添加
<color name="transparency">#0000</color>
透明色这块也可设置为半透明 #96000000(前两位数字既是控制透明度、后六位为颜色)