亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Activity透明/半透明效果的設(shè)置transparent(兩種實現(xiàn)方法)

 更新時間:2013年02月27日 10:45:43   作者:  
兩種方法實現(xiàn)Activity透明/半透明效果的設(shè)置,代碼思路很有調(diào)理,感興趣的朋友可以參考下,希望本文可以幫助到你

方法一
res/values文件夾下建立styles.xml:

復(fù)制代碼 代碼如下:

<?xml version=“1.0″ encoding=“utf-8″?> 
<style name="translucent">
<item name="android:windowBackground">@color/translucent_background</item>
<item name="android:windowIsTranslucent">true</item>
</style>

在該文件夾下在創(chuàng)建文件colors.xml
復(fù)制代碼 代碼如下:

<?xml version=“1.0″ encoding=“UTF-8″?> 
<RESOURCES> 
<color name="translucent_background">#60000000</color> 
</RESOURCES> 

有了這寫設(shè)置,就得告訴Activity用這寫設(shè)置.
AndroidManifest.xml中找到要彈出的activity,加入theme:
android:theme=”@style/translucent”
哎,不錯,確實透明了.但是問題又來了,layout里的button不透明?。绻茏屗麄円餐该骰蛘甙胪该髂??那得設(shè)置窗口屬性.
復(fù)制代碼 代碼如下:

   Window window=getWindow();
         WindowManager.LayoutParams wl = window.getAttributes();
         wl.flags=WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
         wl.alpha=0.6f;      這句就是設(shè)置窗口里崆件的透明度的.0.0全透明.1.0不透明.
         window.setAttributes(wl);
 

方法二
今天試著做activity半透明的效果,做出來之后才發(fā)現(xiàn)想復(fù)雜了!很簡單的幾句就可以實現(xiàn),不多說了,貼代碼!
res/values/styles.xml
復(fù)制代碼 代碼如下:

<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
復(fù)制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
  <color name="transparent_background">#50000000</color> 
</resources> 

注意:color.xml的#5000000前兩位是透明的效果參數(shù)從00--99(透明--不怎么透明),后6位是顏色的設(shè)置
manifest.xml
復(fù)制代碼 代碼如下:

<activity android:name=".TransparentActivity" android:theme="@style/Transparent"> 
</activity> 

java代碼
復(fù)制代碼 代碼如下:

public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setTheme(R.style.Transparent);   
        setContentView(R.layout.transparent);  

相關(guān)文章

最新評論