最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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)文章

最新評論

湘西| 石渠县| 云林县| 揭西县| 砀山县| 宿州市| 泗阳县| 宝山区| 沈阳市| 岳普湖县| 桦南县| 容城县| 泸溪县| 马边| 阿鲁科尔沁旗| 延庆县| 花莲县| 新龙县| 建宁县| 宝应县| 九龙城区| 珲春市| 策勒县| 图们市| 彭阳县| 那坡县| 琼结县| 法库县| 吕梁市| 金秀| 南雄市| 秦皇岛市| 兴和县| 镇远县| 阜平县| 博野县| 铅山县| 蒲江县| 玉屏| 福泉市| 客服|