當前位置:首頁 » 安卓系統 » 安卓如何添加頁面背景透明度

安卓如何添加頁面背景透明度

發布時間: 2024-12-05 04:16:04

『壹』 android 怎麼給一塊區域設置背景半透明

activity的背景透明,只需在只要在配置文件內activity屬性配置內加上android:theme="@android:style/Theme.Translucent"就好了。
但是想要多方面的設置theme的話,就要在values里設置風格先:
加透明:
先在res/values下建colors.xml文件,寫入:
<?xmlversionxmlversion="1.0"encoding="UTF-8"?>
<resources>
<colornamecolorname="transparent">#9000</color><!--透明度-->
</resources>
這個值設定了整個界面的透明度,為了看得見效果,現在設為透明度為56%(9/16)左右。
透明度可以用#9000值調,將這個值(ARGB)改變,就會有不同效果的透明度。
再在res/values/下建styles.xml,設置程序的風格
<?xmlversionxmlversion="1.0"encoding="utf-8"?>
<resources>
<stylenamestylename="Transparent">
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>
</style>
</resources>
加了@+android:style/Animation.Translucent這句的時候就會顯示出此activity會有動畫切換效果
最後一步,把這個styles.xml用在相應的Activity上。即在AndroidManifest.xml中的任意標簽中添加 android:theme="@style/transparent"
如果要設置所有的activity都使用這個風格,就把這句標簽語句添加在中。

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:593
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:888
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:581
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:765
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:684
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1012
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:255
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:113
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:806
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:712