轉載地址:點擊打開鏈接
res/values/styles.xml
<resources>
<style name="Transparent
">
<item name="android:windowBackground">@color/transparent_background</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>
</style>
</resources>
res/values/color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="transparent_background">#50000000</color>
</resources>
注意:color.xml的#5000000前兩位是透明的效果參數從00--99(透明--不怎麼透明),後6位是顏色的設置
manifest.xml
<activity android:name=".TransparentActivity" android:theme="@style/Transparent">
</activity>
java代碼
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.Transparent);
setContentView(R.layout.transparent);
}