Android设置Activity背景为透明style

方法一:

  1. @android:style/Theme.Translucent  
  2. @android:style/Theme.Translucent.NoTitleBar  
  3. @android:style/Theme.Translucent.NoTitleBar.Fullscreen  
  4. 只需要在Manifest中需要透明的Activity内设置theme为以上任意一个就可以了

方法二:

1.自定义style,就像自定义Dialog的style一样,在res-values-color.xml中添加透明颜色值:

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <resources>  
  3.   
  4.     <color name="transparent">#0000</color>  
  5.   
  6. </resources>  


2.在res-values-styles.xml中添加如下:

 
  1. <style name="myTransparent">  
  2.     <item name="android:windowBackground">@color/transparent</item>  
  3.     <item name="android:windowNoTitle">true</item>  
  4.     <item name="android:windowIsTranslucent">true</item>  
  5.     <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>  
  6. </style>  


3.在Manifest中中需要透明的Activity内设置theme为我们自定义的即可

 

    1. android:theme="@style/myTransparent"  
posted @ 2017-07-11 16:26  让学习如呼吸一般自然  阅读(2962)  评论(0编辑  收藏  举报