方法一:
- @android:style/Theme.Translucent
- @android:style/Theme.Translucent.NoTitleBar
- @android:style/Theme.Translucent.NoTitleBar.Fullscreen
- 只需要在Manifest中需要透明的Activity內設置theme為以上任意一個就可以了
方法二:
1.自定義style,就像自定義Dialog的style一樣,在res-values-color.xml中添加透明顏色值:
- <?xml version="1.0" encoding="UTF-8"?>
- <resources>
- <color name="transparent">#0000</color>
- </resources>
2.在res-values-styles.xml中添加如下:
- <style name="myTransparent">
- <item name="android:windowBackground">@color/transparent</item>
- <item name="android:windowNoTitle">true</item>
- <item name="android:windowIsTranslucent">true</item>
- <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
- </style>
3.在Manifest中中需要透明的Activity內設置theme為我們自定義的即可
- android:theme="@style/myTransparent"