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"  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM